0
我想建造URI的使用单个路由模式Symfony2的路由可选参数和格式的路径/图案
1 hello/first.format
2 hello/first
3 hello/first/last.format
4 hello/first/last
其中需要第一和最后和格式下面是可选的。
这是我曾尝试:
hello-route:
pattern: /hello/{fist_name}/{last_name}.{_format}
defaults: { _controller: AcmeHelloBundle:Default:index, last_name:Default, _format:html}
requirements:
_format: html|rss|json
first_name: \w+
last_name: \w+
但由于它匹配2,3是不正确的,而4而不是1.1将不会失败,但是它会匹配{} FIRST_NAME“第一.format“尽管要求。
我该如何使用基本路由来做到这一点?