symfony 2 No route found for “GET /”

后端 未结 7 1283
[愿得一人]
[愿得一人] 2020-12-17 09:54

Symfony2 returns No route found for \"GET /\" when I try to run http://localhost/app_dev.php, but this url works: http://localhost/app_dev.php/hello/Symfony. I removed AcmeD

7条回答
  •  误落风尘
    2020-12-17 10:05

    i could have been only one who made this mistake but maybe not so i'll post.

    the format for annotations in the comments before a route has to start with a slash and two asterisks. i was making the mistake of a slash and only one asterisk, which PHPStorm autocompleted.

    my route looked like this:

    /*
     * @Route("/",name="homepage")
     */
    public function indexAction(Request $request) {
        return $this->render('default/index.html.twig');
    }
    

    when it should have been this

    /**
     * @Route("/",name="homepage")
     */
    public function indexAction(Request $request) {
        return $this->render('default/base.html.twig');
    }
    

提交回复
热议问题