Symfony2:无法找到路径“/api/login_check"的控制器.路由配置错误 [英] Symfony2 : Unable to find the controller for path "/api/login_check". The route is wrongly configured
问题描述
当我在开发环境中一切正常并且我的登录工作正常但是当我将我的应用程序放入服务器并将环境更改为 prod 时我收到此错误
<块引用>Symfony2:无法找到路径/api/login_check"的控制器.路由配置错误.
我知道这个问题在表格中很受欢迎,但我已经查看了所有回复并尝试解决这个问题,但没有人为我工作.
这是我的 security.yml
安全性:编码器:项目\MyBundle\Entity\User: sha512role_hierarchy:角色用户:角色用户ROLE_ADMIN:ROLE_ADMIN供应商:在记忆中:记忆:~用户:实体:类:MyBundle:用户属性:用户名防火墙:开发:模式:^/(_(分析器|wdt)|css|图像|js)/安全:假登录:模式:^/api/登录无状态:真匿名:真实表单登录:检查路径:/api/login_check提供者:用户成功处理程序:lexik_jwt_authentication.handler.authentication_success故障处理程序:lexik_jwt_authentication.handler.authentication_failurerequire_previous_session: 假接口:模式:^/api无状态:真提供者:用户lexik_jwt:~主要的:匿名:~访问控制:- { 路径:^/api/login,角色:IS_AUTHENTICATED_ANONYMOUSLY }- { 路径:^/api,角色:[ROLE_USER, ROLE_ADMIN] }
这是我的routing.yml
应用程序:资源:@AppBundle/Controller/"类型:注释api_login_check:路径:/api/login_check#休息休息:类型:休息资源:项目\MyBundle\Controller\MyController前缀:/api
这是我第一次部署 symfony 项目我花了很多时间解决这个错误希望有人能帮助我..提前致谢
login_check 不适用于GET"请求,您必须在POST"请求上强制使用它.您可以像@federico show you 一样创建它
fos_user_security_check:路径:/login_check默认值:{ _controller:SiteUserBundle:安全:检查}要求:_方法:POST
When I was in dev environnement all goes right and my login work fine but when I put my app in a server and change the environement to prod I get this error
Symfony2 : Unable to find the controller for path "/api/login_check". The route is wrongly configured.
I know this question is very pupular in the forms but I ve look at all the response and try to resolve this problem but no one work for me.
this is my security.yml
security:
encoders:
Project\MyBundle\Entity\User: sha512
role_hierarchy:
ROLE_USER: ROLE_USER
ROLE_ADMIN: ROLE_ADMIN
providers:
in_memory:
memory: ~
user:
entity:
class: MyBundle:User
property: username
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
login:
pattern: ^/api/login
stateless: true
anonymous: true
form_login:
check_path: /api/login_check
provider: user
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure
require_previous_session: false
api:
pattern: ^/api
stateless: true
provider: user
lexik_jwt: ~
main:
anonymous: ~
access_control:
- { path: ^/api/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/api, roles: [ROLE_USER, ROLE_ADMIN] }
and this is my routing.yml
app:
resource: "@AppBundle/Controller/"
type: annotation
api_login_check:
path: /api/login_check
#REST
rest:
type : rest
resource : Project\MyBundle\Controller\MyController
prefix : /api
It's the first time I deploy a symfony project I spent a lot of time with this error hope someone can help me ..thanks in advance
The login_check is not available with "GET" Request, You have to force it on "POST" request.You can create it like @federico show you
fos_user_security_check:
path: /login_check
defaults: { _controller: SiteUserBundle:Security:check }
requirements:
_method: POST
这篇关于Symfony2:无法找到路径“/api/login_check"的控制器.路由配置错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!