diff --git a/cookbook/configuration/environments.rst b/cookbook/configuration/environments.rst index c3fd907859f..b658b16f360 100644 --- a/cookbook/configuration/environments.rst +++ b/cookbook/configuration/environments.rst @@ -212,6 +212,39 @@ environment by using this code and changing the environment string. mode. You'll need to enable that in your front controller by calling :method:`Symfony\\Component\\Debug\\Debug::enable`. +Selecting the Environment for Console Commands +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +By default, Symfony commands are executed in the ``dev`` environment and with the +debug mode enabled. Use the ``--env`` and ``--no-debug`` options to modify this +behavior: + +.. code-block:: bash + + # 'dev' environment and debug enabled + $ php app/console command_name + + # 'prod' environment (debug is always disabled for 'prod') + $ php app/console command_name --env=prod + + # 'test' environment and debug disabled + $ php app/console command_name --env=test --no-debug + +In addition to the ``--env`` and ``--debug`` options, the behavior of Symfony +commands can also be controlled with environment variables. The Symfony console +application checks the existence and value of these environment variables before +executing any command: + +``SYMFONY_ENV`` + Sets the execution environment of the command to the value of this variable + (``dev``, ``prod``, ``test``, etc.); +``SYMFONY_DEBUG`` + If ``0``, debug mode is disabled. Otherwise, debug mode is enabled. + +These environment variables are very useful for production servers because they +allow you to ensure that commands always run in the ``prod`` environment without +having to add any command option. + .. index:: single: Environments; Creating a new environment