How to set the environment in a Symfony2 console command

You have two options that will help you out. You can specify the environment that the console will run in with the --env flag, and use --no-debug to disable debug mode.

php app/console --env=staging your:console:command or php app/console --env=prod your:console:command should do what you’re looking for (the console runs in the dev environment with debug on by default).

You can look at the code of the app/console file for more info.

Leave a Comment