2017-04-17 32 views
0

我生成一個包,但我收到錯誤試圖訪問網址http://localhost/app_dev.php/eventSymfony的航線,但現有的調試器路徑結果

No route found for "GET /event" 

然後我調試與調試路由器:路由器和路由器似乎是精細:

event_homepage    ANY  ANY  ANY  

/hello/{firstName}/{count}   
event_index    GET  ANY  ANY /event/        
event_show     GET  ANY  ANY /event/{id}/show     
event_new     GET|POST ANY  ANY /event/new       
event_edit     GET|POST ANY  ANY /event/{id}/edit     
event_delete    DELETE  ANY  ANY /event/{id}/delete   

我已經自動創建包後,我有這個錯誤:

[ERROR] The bundle's "Resources/config/routing.yml" file cannot be imp 
orted 
from "app/config/routing.yml" because the "EventBundle" bundle is 
already imported. Make sure you are not using two different 
configuration/routing formats in the same bundle because it won't work 

下面是所有的路由結構文件:

/home/stefano/starwarsevents/app/config/routing.yml

event: 
resource: "@EventBundle/Resources/config/routing.yml" 
prefix: /

/家庭/斯特凡諾/ starwarsevents/src目錄/ EventBundle /資源/配置/路由.yml

event_homepage: 
path:  /hello/{firstName}/{count} 
defaults: { _controller: EventBundle:Default:index } 

event_event: 
resource: "@EventBundle/Resources/config/routing/event.yml" 
prefix: /event 

/home/stefano/starwarsevents/src/EventBundle/Resources/config/routing/event.yml

event_index: 
path: /
defaults: { _controller: "EventBundle:Event:index" } 
methods: GET 

event_show: 
path:  /{id}/show 
defaults: { _controller: "EventBundle:Event:show" } 
methods: GET 

event_new: 
path:  /new 
defaults: { _controller: "EventBundle:Event:new" } 
methods: [GET, POST] 

event_edit: 
path:  /{id}/edit 
defaults: { _controller: "EventBundle:Event:edit" } 
methods: [GET, POST] 

event_delete: 
path:  /{id}/delete 
defaults: { _controller: "EventBundle:Event:delete" } 
methods: DELETE 
+0

有可能是'/事件/'和'/事件/ {ID}/show'之間的衝突。嘗試禁用第二個(甚至所有的人),看看你得到任何積極的結果(第一次)。 – Confidence

+0

我試過但沒有。 。 。我編輯了這個帖子並添加了所有的路由結構,我真的不知道這裏有什麼問題 –

回答

1

斜線進行計數和必需的。爲了解決這個問題,我把這個RedirectingController放在我的代碼庫中作爲(幾乎)最終的路線,以便捕獲並重定向到非斜線版本。

但在此期間的URL是目前/event/,不/event。您也可以將替代路線作爲到同一地點的替代路線。

+0

我編輯了這個帖子並添加了所有的路由結構,我真的不知道這裏出了什麼問題 –

+0

可能重新排序路由文件,以使在年底最通用的路徑/路由('event_index')。 –

+0

嘗試過,但沒有發現「GET/event /路由」,這是令人難以置信的 –