未找到Symfony2路由模式路由

时间:2014-04-20 13:59:27

标签: php symfony routing

我有一个非常简单的理解问题

不可能有这样的路由模式吗?

foobar_foobar_videos_all:
    pattern:  /video
    defaults: { _controller: foobarfoobarBundle:Content:showVideos }

foobar_foobar_videos_by_category:
    pattern:  /video/{category}
    defaults: { _controller: foobarfoobarBundle:Content:showVideosByCategory }

foobar_foobar_videos_by_category_and_offset:
    pattern:  /video/{category}/page/{offset}
    defaults: { _controller: foobarfoobarBundle:Content:showVideosByCategory }

这样第一条路线不起作用,打印

"No route found for "GET /video"

而其他人的工作完美。

我如何路由到/视频?

1 个答案:

答案 0 :(得分:0)

解决方案是将/ video模式放到最后

foobar_foobar_videos_by_category:
    pattern:  /video/{category}
    defaults: { _controller: foobarfoobarBundle:Content:showVideosByCategory }

foobar_foobar_videos_by_category_and_offset:
    pattern:  /video/{category}/page/{offset}
    defaults: { _controller: foobarfoobarBundle:Content:showVideosByCategory }

foobar_foobar_videos_all:
    pattern:  /video
    defaults: { _controller: foobarfoobarBundle:Content:showVideos }