Hello!

I do a test on symfony 3 (before that I worked with Laravel).

I just can not figure out how to configure the display of content in the prod-environment. Routes through app_dev.php displayed normally, and without it, 500 returns an error.

Tell me, please, where to dig? Information on this issue on the official website has not yet been found, and deadlines are tight.

In the log the following:

 [2016-04-18 09:13:08] request.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET /address"" at D:\webdev\symfony\site.lc\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\EventListener\RouterListener.php line 123 {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException(code: 0): No route found for \"GET /address\" at D:\\webdev\\symfony\\site.lc\\vendor\\symfony\\symfony\\src\\Symfony\\Component\\HttpKernel\\EventListener\\RouterListener.php:123, Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException(code: 0): at D:\\webdev\\symfony\\site.lc\\var\\cache\\prod\\appProdUrlMatcher.php:46)"} [] 
  • in logs what? - etki

1 answer 1

So, it's all in the cache.

Since the prod environment is optimized for speed, configuration, routing, and Twig templates are compiled into bare PHP classes and cached. If you change something in the dev environment and want to see how it looks in the prod environment, then you need to clear the cache of this environment ( prod ); if you do not, you will see what was compiled and cached earlier.

You can clear the cache in symfony using the console:

 php bin/console cache:clear 

The command above will clear the environment dev cache, since by default console commands are executed in it ( dev environment)

To clear the cache for prod or another environment, add the appropriate option:

 php bin/console cache:clear --env=prod 

Alternative option:

 php bin/console cache:clear -e prod 

Sources: