Symfony security core Interface doesnt load

A simple but silly problem is blocking me on symfony tonight…
I need to use the UserInterface class of the security component to retrieve information about the current user. However symfony tells me that this class doesn’t exist. I checked "security" is well installed and the paths are good…

My code :

<?php

namespace AppController;

use AppEntityProfile;
use AppEntityCandidature;
use AppFormCandidatureType;
use SymfonyComponentHttpFoundationRequest;
use SymfonyComponentHttpFoundationResponse;
use SymfonyComponentRoutingAnnotationRoute;
use SymfonyComponentSecurityCoreUserUserInterface;
use SymfonyBundleFrameworkBundleControllerAbstractController;

class CandidateController extends AbstractController
{
    /**
     * @Route("/candidate", name="candidate")
     */
    public function new(Request $request, UserInterface $user): Response
    {
        // NEED TO BE CONNECTED !!
        if ($user->getUsername()) {
            // SOME CODE ...........

        } else {
            return $this->redirectToRoute('security_login');
        }
    }
}

The error i get (screenshot)

Error i get (quote)

Cannot autowire argument $user of
"AppControllerCandidateController::new()": it references interface
"SymfonyComponentSecurityCoreUserUserInterface" but no such
service exists. Did you create a class that implements this interface?

Thank you if you can help me,
Merry Christmas and good evening 🙂

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *