Skip to content

Commit 12029a0

Browse files
committed
Merge branch '5.4' into 6.3
* 5.4: Prioritize the dump-env Composer command
2 parents b038b1f + c2969fb commit 12029a0

File tree

1 file changed

+29
-19
lines changed

1 file changed

+29
-19
lines changed

configuration.rst

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -844,33 +844,43 @@ In production, the ``.env`` files are also parsed and loaded on each request. So
844844
the easiest way to define env vars is by creating a ``.env.local`` file on your
845845
production server(s) with your production values.
846846

847-
To improve performance, you can optionally run the ``dotenv:dump`` command (available
848-
in :ref:`Symfony Flex <symfony-flex>` 1.2 or later). The command is not registered
849-
by default, so you must register first in your services:
847+
To improve performance, you can optionally run the ``dump-env`` Composer command:
850848

851-
.. code-block:: yaml
849+
.. code-block:: terminal
852850
853-
# config/services.yaml
854-
services:
855-
Symfony\Component\Dotenv\Command\DotenvDumpCommand:
856-
- '%kernel.project_dir%/.env'
857-
- '%kernel.environment%'
851+
# parses ALL .env files and dumps their final values to .env.local.php
852+
$ composer dump-env prod
858853
859-
In PHP >= 8, you can remove the two arguments when autoconfiguration is enabled
860-
(which is the default):
854+
.. sidebar:: Dumping Environment Variables without Composer
861855

862-
.. code-block:: yaml
856+
If you don't have Composer installed in production, you can use the
857+
``dotenv:dump`` command instead (available in :ref:`Symfony Flex <symfony-flex>`
858+
1.2 or later). The command is not registered by default, so you must register
859+
first in your services:
863860

864-
# config/services.yaml
865-
services:
866-
Symfony\Component\Dotenv\Command\DotenvDumpCommand: ~
861+
.. code-block:: yaml
867862
868-
Then, run the command:
863+
# config/services.yaml
864+
services:
865+
Symfony\Component\Dotenv\Command\DotenvDumpCommand:
866+
- '%kernel.project_dir%/.env'
867+
- '%kernel.environment%'
869868
870-
.. code-block:: terminal
869+
In PHP >= 8, you can remove the two arguments when autoconfiguration is enabled
870+
(which is the default):
871871

872-
# parses ALL .env files and dumps their final values to .env.local.php
873-
$ APP_ENV=prod APP_DEBUG=0 php bin/console dotenv:dump
872+
.. code-block:: yaml
873+
874+
# config/services.yaml
875+
services:
876+
Symfony\Component\Dotenv\Command\DotenvDumpCommand: ~
877+
878+
Then, run the command:
879+
880+
.. code-block:: terminal
881+
882+
# parses ALL .env files and dumps their final values to .env.local.php
883+
$ APP_ENV=prod APP_DEBUG=0 php bin/console dotenv:dump
874884
875885
After running this command, Symfony will load the ``.env.local.php`` file to
876886
get the environment variables and will not spend time parsing the ``.env`` files.

0 commit comments

Comments
 (0)