我想創建一個基於symfony.com教程的symfony 4用戶登錄。Symfony 4 AuthenticationUtils
我用下面的代碼使用了基本的services.yaml文件。
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:
控制器 「應用程序\控制器\ SecurityController ::在loginAction()」 要求您提供的 「$ authUtils」 參數的值。參數是可爲空的,並且沒有提供空值,沒有提供默認值,或者因爲在這之後有一個非可選參數。
我不知道如何解決這個問題。有人有建議嗎?
我在4.0上遇到了同樣的問題,下面的兩條建議無效。我也嘗試注入構造函數(應該不重要),但結果相同。很奇怪,因爲我在測試3.4時遇到了同樣的問題,但最終得到了它的工作。這些修補程序是否適用於您@Erik –