欢迎来到我的第一个堆栈帖子:)
php 7.2 symfony 4.2 上的问题。这两天我想不通。
尝试通过带有标头 Content-Type application/json 的 POST /api/login_check 访问时,我得到了以下日志。
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 中的 jwt.yaml 定义为: api_login_check: path: /api/login_check
帮助将不胜感激:)