简体   繁体   English

找不到Symfony路由,但存在于调试器路由结果中

[英]Symfony route not found but existing in debugger route result

I generated a bundle but I receive error trying to access url http://localhost/app_dev.php/event : 我生成了一个包,但是在尝试访问URL http://localhost/app_dev.php/event时收到错误消息:

No route found for "GET /event"

then I debugged the router with debug:router, and the router seems to be fine: 然后我用debug:router调试了路由器,路由器似乎正常了:

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        

after I have created the bundle automatically I had this error: 自动创建捆绑包后,出现以下错误:

[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

Below is all the routing structure files: 以下是所有路由结构文件:

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

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

/home/stefano/starwarsevents/src/EventBundle/Resources/config/routing.yml /home/stefano/starwarsevents/src/EventBundle/Resources/config/routing.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 /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

Slashes are counted and required. 斜杠是必需的。 To help with this, I've put this RedirectingController in my codebase as a (nearly) final route, to catch and redirect to the slash-less version, should it happen. 为了解决这个问题,我将RedirectingController放在了我的代码库中,作为(几乎)最终的路由,以在发生这种情况时捕获并重定向到无斜杠版本。

But in the meantime the URL is currently /event/ , not /event . 但是与此同时,URL当前是/event/ ,而不是/event You could also put the alternate one in as an alternate route to the same place. 您也可以将替代路线作为到达同一地点的替代路线。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM