I try to put symfony 3 into prod mode. Do I understand correctly that for this it is enough to remove from the address /app_dev.php and reset the cache?

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

After that, going to the site, I again see the debagbar, where it says Environment dev , i.e. requests go through web/app_dev.php .

What am I doing wrong?

  • check .htaccess? - Ipatiev
  • @ Ipatiev he is original - Pavel Sokolov
  • your web server drives traffic to app_dev.php, symphony settings have nothing to do with it - etki
  • Well, in the original, what is written? app.php or app_dev? - Ipatiev
  • @Ipatiev in the original, everything goes to app.php, but I note that the address /app.php gives 404, although the file itself is present - Pavel Sokolov

2 answers 2

Server settings

Make sure that the server sends requests to the correct file in the root (app.php | app_dev.php). To do this, just stick to the beginning of the file app.php exit('true'); , open the root page of the site and everything will become clear: you saw true - the file is correct, you did not see - we are looking at the server settings. Server settings depend on whether you use apache or nginx. If apache , look at the root of the site .htaccess file. It should include, among other things, the string RewriteRule .? %{ENV:BASE}/app.php [L] RewriteRule .? %{ENV:BASE}/app.php [L] . If your file is original, everything should be fine there. For nginx , unfortunately, everything is a bit more complicated and the settings should be crammed with hands. Approximately, such a block should be present in your config so that requests to the root fall on app.php:

 location ~ \.php$ { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index app.php; include fastcgi_params; } 

app.php

If requests come to the correct file, app.php, but the site is still opened in the dev-version - you need to check the contents of app.php. For example, this is how the code of this file looks like to me:

 <?php use Symfony\Component\ClassLoader\ApcClassLoader; use Symfony\Component\HttpFoundation\Request; $loader = require_once __DIR__.'/../app/bootstrap.php.cache'; $apcLoader = new ApcClassLoader(strtolower($_SERVER['HTTP_HOST']) . "_", $loader); $loader->unregister(); $apcLoader->register(true); require_once __DIR__.'/../app/AppKernel.php'; $kernel = new AppKernel('prod', false); $kernel->loadClassCache(); $request = Request::createFromGlobals(); $response = $kernel->handle($request); $response->send(); $kernel->terminate($request, $response); 

Notice the line $kernel = new AppKernel('prod', false); In the context of the problem, it is the most important. This is where the environment is set by the first argument and the second debug . Here you should have exactly these values.

In addition, you probably need to run the command to run the prod-environment

 php ./app/console assetic:dump 

which generates all the necessary statics. But here the situation is ambiguous, perhaps your system is configured to generate static on the fly.

  • It was in the server settings. Thanks for the tip. - Pavel Sokolov

Symfony nothing to do with. The case at Homestead (the same VM from Laravel). It turns out that in Homestead.yaml in the sites section add type: symfony

 - map: site.app to: /home/vagrant/Code/site/web type: symfony 

then VM creates a config under symfony in the 'dev' mode, where in /etc/nginx/sites-enabled/site.app in the location writes the path to app_dev.php

 location / { try_files $uri $uri/ /app_dev.php?$query_string; } 

This is worth watching first.