今天我的Symfony应用程序遇到了一个神秘的问题。
我创造了一条与另一条路线相冲突的新路线。我更改了订单,但问题仍然存在。
我的路线是:
# imported and prefixed routing.yml file
my_new_route:
path: /activation-token/{activation-token}
defaults: { _controller: MyUserBundle:User:getLicenseeIdByActivationToken }
methods: [GET]
当我启动bin/console debug:router
命令时,我的路线已经注册:
$ bin/console debug:router --show-controllers | grep my_new_route
my_new_route GET ANY ANY /api/v1/users/activation-token/{activation-token} FfbEasiUserBundle:Users:getLicenseeIdByActivationToken
然后我删除了冲突的路由,只是为了测试,并尝试使用bin/console router:match
命令来检查我的路由是否匹配。我有以下输出:
$ bin/console router:match --method GET /api/v1/users/activation-token/a
[ERROR] None of the routes match the path "/api/v1/users/activation-token/{application-token}"
我承认我不明白我目前的配置出了什么问题。
如果有人有线索,请分享:D!
编辑:我清除了缓存;)
只需将参数更改为简单的camelCase即可。symfony路由器不喜欢连字符的路由params;)