2016-07-22 127 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路由器不喜歡連字符路由參數;)