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
This work for me:
cache:clear --env=prod
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');
}
The above answers are wrong, respectively aren't answering why you're having troubles viewing the demo-content prod-mode.
Here's the correct answer: clear your "prod"-cache:
php app/console cache:clear --env prod
Using symfony 2.3 with php 5.5 and using the built in server with
app/console server:run
which should output something like:
Server running on http://127.0.0.1:8000
Quit the server with CONTROL-C.
then go to http://127.0.0.1:8000/app_dev.php/app/example
this should give you the default, which you can also find the default route by viewing src/AppBundle/Controller/DefaultController.php
The problem is that you don't have a route for /
. Change your definition to this:
ShopMyShopBundle_homepage:
pattern: /
defaults: { _controller: ShopMyShopBundle:Main:index }
requirements:
_method: GET
Prefix is the prefix for url routing. If it's equals to '/' it means it will have no prefix. Then you defined a route with pattern "it should start with /hello".
To create a route for '/' you need to add these lines in your src/Shop/MyShopBundle/Resources/config/routing.yml :
ShopMyShopBundle_homepage:
pattern: /
defaults: { _controller: ShopMyShopBundle:Main:index }