How to set the environment in a Symfony2 console command

后端 未结 6 1181
清歌不尽
清歌不尽 2021-01-31 14:46

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

6条回答
  •  礼貌的吻别
    2021-01-31 15:40

    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.

提交回复
热议问题