0
我在启动服务器并尝试访问http://127.0.0.1:8000时收到错误Unable to generate a URL for the named route "login" as such route does not exist.
。无法为指定的路由“登录”生成URL
到/登录直接访问,得到:No route found for "GET /login"
这是symfony3和无FOSBUNDLE! 基于symfony3 cookbook traditional log form。
security.yml:
securityController.php:
// src/AppBundle/Controller/SecurityContoller.php
namespace AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
class SecurityController extends Controller
{
/**
* @Route("/login", name="login")
*/
public function loginAction(Request $request)
{
$authenticationUtils = $this->get('security.authentication_utils');
// login error, if there is one
$error = $authenticationUtils->getLastAuthenticationError();
// last username entered
$lastUsername = $authenticationUtils->getLastUsername();
return $this->render(
'security/login.html.twig',
array(
'last_username' => $lastUsername,
'error' => $error,
)
);
}
}
请问你的routing.yml文件是什么样子? – Laoneo
它的默认值是否需要手动添加到routing.yml中,即使使用注释? – Diamonte
是的,你需要添加一个路由文件。我发布了一个答案,需要什么。 – Laoneo