Mayor of the Plattenbaus
Mayor of the Plattenbaus

Reputation: 1256

Make a local Symfony 2.8 app act like it's in a prod environment

I have an application based on Symfony 2.8. A feature is working well in my local dev environment but failing in production. I want to make my local environment use prod mode in order to hopefully replicate the problem. What I have tried:

export SYMFONY_ENV=prod
app/console cache:clear --no-warmup

This appeared at first to be working, as I got a message about the cache being cleared in the prod environment, but when I loaded the app, the debug toolbar was visible and said I was in dev mode.

I have also tried looking in both parameters.yml and config.yml for any denotation of the environment. I didn't find anything.

What should I try next?

Upvotes: 0

Views: 317

Answers (2)

Pavel Vasiluk
Pavel Vasiluk

Reputation: 317

Well, in symfony2 dev mode is being accessed through file web/app_dev.php, prod - web/app.php. So if you are using your own local web-server (apache or nginx), in order to see the app in prod mode, you may want to provide your web-server the default symfony configuration, e.g. as described here : https://symfony.com/doc/2.8/setup/web_server_configuration.html#nginx

In case you are using symfony built-in web-server, you may want to use the solution ox160d05d provided. I would recommend using own local web-server though.

Upvotes: 0

ox160d05d
ox160d05d

Reputation: 761

The answer can depend on a lot of factors: what web-server is used, what web-server config is used, do you use php-fpm or else, etc.

Console commands like "export SYMFONY_ENV=prod" set environment only for console commands in the same session. But they can't affect your web server behavior.

When you open a page of your project in a browser, the application doesn't know anything about commands what you have typed in a terminal. If you see a debug console probably the app entry point is "web/app_dev.php", and the environment is defined here like:

// web/app_dev.php

$kernel = new AppKernel('dev', true);

Try to change 'dev' by 'prod'

Upvotes: 1

Related Questions