Hopefully a simple question – how does one specify which environment to use when running a console command in Symfony2. I’ve created a few commands, however I would like to run them in the context of my ‘staging’ environment when on my staging server and my ‘prod’ environment when on my production server (the different environments define different database connections). How do I configure and pass this information to my console command?
Share
You have two options that will help you out. You can specify the environment that the console will run in with the
--envflag, and use--no-debugto disable debug mode.php app/console --env=staging your:console:commandorphp app/console --env=prod your:console:commandshould do what you’re looking for (the console runs in thedevenvironment with debug on by default).You can look at the code of the
app/consolefile for more info.