2016-07-22 133 views
0

今天我的Symfony应用程序出现了一个神秘的问题。找到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!

编辑:我清除缓存;)

回答

1

只要改变你的参数去一个简单的驼峰之一。 symfony路由器不喜欢连字符路由参数;)