pmoubed
pmoubed

Reputation: 3922

Symfony2, How to change environment?

I have read a lot about the clear cache command for symfony2, but I have this question :

Is php app/console cache:clear --env=prod with --env, changes the environment or just clean the cache for that environment?

If only clear the cache for that environment, then what is this line mean in app.php :

$kernel = new AppKernel('prod', false); 

I think when I want to use Symfony2 Production Environment I have to change that line to

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

Am I in the right spot?

Upvotes: 11

Views: 40480

Answers (2)

Ahmed Siouani
Ahmed Siouani

Reputation: 13891

To change the environment you've to change your front controller. Symfony2 provide by default three environments and a front controller for each one of them with a specific configuration files > See more

When you execute cache:clear command for a specific environment, it just clears the cache for the given environment. To change your environment, you've just to change your front controller (app.php / app_dev.php / app_test.php)

You can also create new environments with a specific configuration

Upvotes: 7

Peter Bailey
Peter Bailey

Reputation: 105878

The two constructor arguments for Symfony\Component\HttpKernel\Kernel are $environment and $debug.

So, to answer your question directly, app.php already uses the production environment. You'll notice that app_dev.php instantiates the kernel like this

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

So, the environment name that you pass to the kernel constructor maps to the environment name you'd use in console commands (i.e., the --env).

Does that clear it up for you?

Upvotes: 19

Related Questions