我尝试添加路线:
- POST /user - 创建用户
- GET /user - 获取用户列表
我的app/config/routing.yml:
app:
resource: "@AppBundle/Resources/route/app.yml"
prefix: /
AppBundle/Resources/route/app.yml:
user:
resource: "@AppBundle/Resources/route/user.yml"
prefix: /user
AppBundle/Resources/route/user.yml:
list:
path: /
defaults: { _controller: AppBundle:User:list }
methods: GET
create:
path: /
defaults: { _controller: AppBundle:User:create }
methods: POST
我已经安装了friendsofsymfony/rest-bundle(UserController 扩展了 FOSRestController)
应用程序/配置/安全.yml:
security:
providers:
in_memory:
memory: ~
firewalls:
api:
pattern: ^/
stateless: true
guard:
authenticators:
- lexik_jwt_authentication.jwt_token_authenticator
当我请求路由 POST /user 时,出现错误
No route found for "POST /user": Method Not Allowed (Allow: GET)