我正在嘗試將 Symfony 應用程式從 4.1 升級到 4.4,但我在 SecurityController 中出現身份驗證錯誤
public function loginAction (Request $request)
{
/* var AuthenticationUtils $authUtils */
$authUtils= $this->get('security.authentication_utils');
// get the login error if there is one
$error = $authUtils->getLastAuthenticationError();
// last username entered by the user
$lastUsername = $authUtils->getLastUsername();
return $this->render('admin/user/login.html.twig', array(
'error' => $error,
'last_username' => $lastUsername,
));
}
但升級后我有這個錯誤

我該如何解決這個錯誤?
uj5u.com熱心網友回復:
..正如@dbrunmann 所提到的
public function loginAction (Request $request, AuthenticationUtils $authUtils)
{
// get the login error if there is one
$error = $authUtils->getLastAuthenticationError();
// last username entered by the user
$lastUsername = $authUtils->getLastUsername();
return $this->render('admin/user/login.html.twig', array(
'error' => $error,
'last_username' => $lastUsername,
));
}
使用php bon\console debug:autowiring <some_service_name>- 找出使用哪種 typhint 來獲得正確的服務
例如php bin\console debug:autowiring utils會給你

轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/316236.html
