Php 未找到Symfony路由,但在调试器路由结果中存在
我生成了一个捆绑包,但在尝试访问url时收到错误: 然后我用debug:router调试了路由器,路由器看起来很好:Php 未找到Symfony路由,但在调试器路由结果中存在,php,symfony,Php,Symfony,我生成了一个捆绑包,但在尝试访问url时收到错误: 然后我用debug:router调试了路由器,路由器看起来很好: event_homepage ANY ANY ANY /hello/{firstName}/{count} event_index GET ANY ANY /event/ event_sho
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: /
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.yml
event:
resource: "@EventBundle/Resources/config/routing.yml"
prefix: /
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
斜杠是计算出来的,并且是必需的。为了帮助实现这一点,我在代码库中加入了这一点,作为一个接近最终的路径,以捕获并重定向到无斜杠版本(如果发生)
但同时URL当前为/event/,而不是/event。您还可以将备用路径作为到同一位置的备用路径放入。在/event/和/event/{id}/show之间可能存在冲突。试着禁用第二个,甚至所有其他的,看看你是否得到任何积极的结果第一。我尝试了,但没有。我编辑了这篇文章并添加了所有的路由结构,我真的不知道这里出了什么问题我编辑了这篇文章并添加了所有的路由结构,我真的不知道这里出了什么问题可能对路由文件进行了重新排序,以在最后生成最通用的路径/路由事件索引。尝试了,但找不到GET/event/的路由。这真是难以置信。它正在工作,但只在内置服务器上,在apache上。请不要。然后检查您的apache虚拟主机设置和规则。