Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2, How to change environment?

Tags:

php

symfony

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?

like image 837
pmoubed Avatar asked Jun 05 '12 21:06

pmoubed


1 Answers

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?

like image 146
Peter Bailey Avatar answered Oct 10 '22 11:10

Peter Bailey