【发布时间】:2015-10-21 14:04:42
【问题描述】:
我正在尝试创建一个相当复杂的路由模式,但我被卡住了。
我不想匹配的路线
/books indexAction
/books/show showAction
/books/authorname indexAction
/books/authorname/show showAction
当前设置
Routing.yml
actions:
resource: routing/actions.yml
prefix: /books/{authorname}
requirements:
authorname: ".*"
defaults:
authorname: ''
routing/actions.yml
books_index:
path: ""
defaults: { _controller:bookController:indexAction }
books_show:
path: "/show"
defaults: { _controller:bookController:showAction }
此设置当前仅匹配:
/books/ indexAction
/books/show showAction
/books/authorname indexAction
/books/authorname/show showAction
但不是
/books
我将这些路由分成两个文件的原因是实际上动作包含更多路由,还有其他路由类别然后动作。
我知道我可以在没有前缀的情况下手动定义 /books 路由,但我想避免这种情况,因为此架构将用于许多不同的模块。
【问题讨论】:
标签: symfony