2014-01-21 03:23 阅读 32


I have a project in sympfony. Im trying to add a new page, and i have done usual steps, but nothing seems to work. I have added the following to src/ITWB/FrontBundle/Resources/config/routing.yml:

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

In my src/ITWB/FrontBundle/Controller/FooterController.php i have added this:

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

But it's not working. I have tried putting and "echo" inside the action, and it isnt displaying, so, the problem is in the routing, its not being recognized. I have also tried with other names and it's the same.

What can i do ? Thanks

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

3条回答 默认 最新

  • 已采纳
    dongqing314511 dongqing314511 2014-01-21 11:30

    Take care of indent, like Wouter J says.

    You can access abcCenter via (not if your website is running local, otherwise you have to clear cache:

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

    How to deploy a Symfony2 application.

    点赞 评论 复制链接分享
  • doufulian4076 doufulian4076 2014-01-21 05:38

    The first place I would look: in app/config/routing.yml, do you have a reference to your bundle's routing.yml?

    The app/config/routing.yml file should contain a couple of lines something like this:

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

    Of course maybe you've done this already as part of the "usual steps" you mention?

    点赞 评论 复制链接分享
  • dongzao4503 dongzao4503 2014-01-21 09:02

    You forgot the indent the options. Indenting is a really important aspect of Yaml:

        pattern: /abcCenter
        defaults: { _controller: ITWBFrontBundle:Footer:abcCenter }
    点赞 评论 复制链接分享