Symfony,routing.yml不起作用

时间:2014-01-21 03:23:27

标签: php symfony controller routing

我有一个同情的项目。 我试图添加一个新的页面,我已经做了通常的步骤,但似乎没有任何工作。 我已将以下内容添加到src / ITWB / FrontBundle / Resources / config / routing.yml中:

itwb_front_abc:
pattern: /abcCenter
defaults: { _controller: ITWBFrontBundle:Footer:abcCenter }

在我的src / ITWB / FrontBundle / Controller / FooterController.php中我添加了这个:

public function abcCenterAction() { 
return $this->render('ITWBFrontBundle::test.html.twig');
}

但它不起作用。 我已经尝试在操作中放置并“回显”,并且它没有显示,因此,问题在于路由,domain.com/abcCenter无法识别。我也试过其他名字而且也一样。

我该怎么办? 感谢

3 个答案:

答案 0 :(得分:1)

你忘记了缩进选项。缩进是Yaml非常重要的一个方面:

itwb_front_abc:
    pattern: /abcCenter
    defaults: { _controller: ITWBFrontBundle:Footer:abcCenter }

答案 1 :(得分:0)

我要看的第一个地方:在app / config / routing.yml中,您是否有对bundle的routing.yml的引用?

app / config / routing.yml文件应包含以下几行:

front_bundle:
    resource: "@FrontBundle/Resources/config/routing.yml"

当然,您可能已经将此作为您提及的“常规步骤”的一部分吗?

答案 2 :(得分:0)

像Wouter J说的那样照顾缩进。

如果您的网站在本地运行,您可以通过domain.com/app_dev.php/abcCenter(不是domain.com/abcCenter)访问abcCenter,否则您必须清除缓存:

php app/console cache:clear --env=prod --no-debug

How to deploy a Symfony2 application

相关问题