欢迎使用我的第一篇堆栈文章:)
php 7.2 symfony 4.2上的问题。我两天都想不出这件事。
当我尝试通过POST /api/login_check访问头文件Content-Type application/json时,我得到了以下日志。
2019-01-10T23:33:11+01:00 [info] Matched route "api_login_check".
2019-01-10T23:33:11+01:00 [info] Populated the TokenStorage with an anonymous Token.
2019-01-10T23:33:11+01:00 [warning] Unable to look for the controller as the "_controller" parameter is missing.
2019-01-10T23:33:11+01:00 [error] Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "Unable to find the controller for path "/api/login_check". The route is wrongly configured." at /home/mateusz/Workspace/api-platform/vendor/symfony/http-kernel/HttpKernel.php line 134
[Thu Jan 10 23:33:11 2019] 127.0.0.1:56616 [404]: /api/login_check
我的配置:
security:
encoders:
App\Entity\User: bcrypt
providers:
database:
entity:
class: App\Entity\User
property: username
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
anonymous: true
api:
pattern: ^/api
stateless: true
anonymous: true
json_login:
check_path: /api/login_check
success_handler: lexik_jwt_authentication.handler.authentication_success
failure_handler: lexik_jwt_authentication.handler.authentication_failure
guard:
authenticators:
- lexik_jwt_authentication.jwt_token_authenticator
access_control:
- { path: ^/api/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/api, roles: IS_AUTHENTICATED_FULLY }
/routes中的路径定义为: api_login_check: jwt.yaml : /api/login_check
非常感谢您的帮助:)
发布于 2019-01-14 23:39:24
移走或放在底部:
main:
anonymous: true
由于该条目,路由器永远无法获取您的api
防火墙。
https://stackoverflow.com/questions/54137981
复制相似问题