Symfony 3.3 找不到路径"/login/check"的控制器。路由配置错误



我知道已经问了一些问题,尽管在检查20倍之后,它是否与其他情况不一样,我还没有解决我的案件的解决方案。

我已经设置了自己的身份验证侦听器。无论它是否存储令牌(处理时返回null),我都会收到相同的错误消息。不知道有什么问题,因为/login/check 路径在主要防火墙后面,请参见 security.yml

    login:
        pattern:  ^/login$
        security: false
    main:
        pattern: ^/
        anonymous: ~
        zwzt:
            provider: in_memory
        logout:
            path: logout
            target: /login

我的 routing.yml 文件:

logout:
    path:   /logout
login_check:
    path:   /login/check

有什么想法在这里怎么了?

按要求的一些日志:

[2017-08-30 12:44:39] request.INFO: Matched route "login_check". {"route":"login_check","route_parameters":{"_route":"login_check"},"request_uri":"http://localhost/login/check","method":"POST"} []
[2017-08-30 12:44:39] security.INFO: Populated the TokenStorage with an anonymous Token. [] []
[2017-08-30 12:44:39] request.WARNING: Unable to look for the controller as the "_controller" parameter is missing. [] []
[2017-08-30 12:44:39] request.ERROR: Uncaught PHP Exception SymfonyComponentHttpKernelExceptionNotFoundHttpException: "Unable to find the controller for path "/login/check". The route is wrongly configured." at /var/www/v2/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php line 137 {"exception":"[object] (Symfony\Component\HttpKernel\Exception\NotFoundHttpException(code: 0): Unable to find the controller for path "/login/check". The route is wrongly configured. at /var/www/v2/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:137)"} []

您可能需要为自定义check_pathlogout.path配置默认的_controller,尽管这将永远不会执行。Symfony将首先拦截此并自动处理注销:

public function logoutAction()
{
    throw new Exception('This should never be reached!');
}

对于check_path控制器相同,但是作为技巧,您可以配置与不再使用的login_path相同的路径。

最新更新