Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony 4 AuthenticationUtils

I am trying to create a user login with symfony 4 based on the tutorial from symfony.com.

I used the basic services.yaml file with the code below.

https://symfony.com/doc/current/security/form_login_setup.html

public function loginAction(Request $request, \Twig_Environment $twigRenderer,AuthenticationUtils $authUtils)
{

    // get the login error if there is one
    $error = $authUtils->getLastAuthenticationError();

    // last username entered by the user
    $lastUsername = $authUtils->getLastUsername();


    return new response($twigRenderer->render('security/login.html.twig', array(
        'last_username' => $lastUsername,
        'error'         => $error,
        )
    ));
}

Errror:

Controller "App\Controller\SecurityController::loginAction()" requires that you provide a value for the "$authUtils" argument. Either the argument is nullable and no null value has been provided, no default value has been provided or because there is a non optional argument after this one.

I don`t know how to solve this. Does someone have a suggestion?

like image 488
Erik Avatar asked Dec 02 '17 19:12

Erik


1 Answers

I was with the same problem .. Try to run the command:

composer require security
like image 193
Guhh Avatar answered Oct 13 '22 23:10

Guhh