应用程序/config/routing_dev.yml:
people:
resource: "@myPeopleBundle/Resources/config/routing.yml"
prefix: /people
myPeopleBundle/Resources/config/routing.yml:
people_homepage:
pattern: /{name}
defaults: { _controller: myPeopleBundle:Default:index, name: Foo }
people_homepage2:
pattern: /
defaults: { _controller: myPeopleBundle:Default:index, name: Bar }
myPeopleBundle:控制器:DefaultController.php:
...
public function indexAction($name) {
return $this->render('myPeopleBundle:Default:index.html.twig', array('name' => $name));
}
...
myPeopleBundle:默认:index.html.twig:
Hello {{ name }}!
web/app_dev.php/people ->
你好福!
web/app_dev.php/people/ ->
酒吧你好!
为什么不一样?people_homepage
路由为什么不匹配第二个 ( ) web/app_dev.php/people/
url?
但是,如果我将其设置为prefix
,/
我会得到相同的输出:
web/app_dev.php ->
Hello Foo!
web/app_dev.php/ ->
你好福!