'Symfony 6, Problem with errors pages (Unable to generate a URL)
Strange behavior. If enter any phrase in the link, that should lead to a 404 page. Instead, an 404 error is raised:
Unable to generate a URL for the named route "login" as such route does not exist.
<a href="{{path('login')}}">Login</a>
Even if this part of the code is commented out, there will be an error for every other path.
For all other cases, everything works and controller links are generated.
Controller:
/**
* @Route("/login", name="login")
* @param AuthenticationUtils $authenticationUtils
* @return Response
*/
public function userLogin(AuthenticationUtils $authenticationUtils)
{
if ($this->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
return $this->redirect($this->generateUrl('home_page'));
}
// get the login error if there is one
$error = $authenticationUtils->getLastAuthenticationError();
// last username entered by the user
$lastUsername = $authenticationUtils->getLastUsername();
return $this->render(
'user/security/login.html.twig', [
'last_username' => $lastUsername,
'error' => $error,
]
);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
