8000 minor #18890 Prioritize the dump-env Composer command (javiereguiluz) · symfony/symfony-docs@c2969fb · GitHub
[go: up one dir, main page]

Skip to content

Commit c2969fb

Browse files
committed
minor #18890 Prioritize the dump-env Composer command (javiereguiluz)
This PR was merged into the 5.4 branch. Discussion ---------- Prioritize the dump-env Composer command Fixes #18605. Commits ------- 448be85 Prioritize the dump-env Composer command
2 parents 4eaf1d9 + 448be85 commit c2969fb

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
@@ -831,33 +831,43 @@ In production, the ``.env`` files are also parsed and loaded on each request. So
831831
the easiest way to define env vars is by creating a ``.env.local`` file on your
832832
production server(s) with your production values.
833833

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

838-
.. code-block:: yaml
836+
.. code-block:: terminal
839837
840-
# config/services.yaml
841-
services:
842-
Symfony\Component\Dotenv\Command\DotenvDumpCommand:
843-
- '%kernel.project_dir%/.env'
844-
- '%kernel.environment%'
838+
# parses ALL .env files and dumps their final values to .env.local.php
839+
$ composer dump-env prod
845840
846-
In PHP >= 8, you can remove the two arguments when autoconfiguration is enabled
847-
(which is the default):
841+
.. sidebar:: Dumping Environment Variables without Composer
848842

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

851-
# config/services.yaml
852-
services:
853-
Symfony\Component\Dotenv\Command\DotenvDumpCommand: ~
848+
.. code-block:: yaml
854849
855-
Then, run the command:
850+
# config/services.yaml
851+
services:
852+
Symfony\Component\Dotenv\Command\DotenvDumpCommand:
853+
- '%kernel.project_dir%/.env'
854+
- '%kernel.environment%'
856855
857-
.. code-block:: terminal
856+
In PHP >= 8, you can remove the two arguments when autoconfiguration is enabled
857+
(which is the default):
858858

859-
# parses ALL .env files and dumps their final values to .env.local.php
860-
$ php bin/console dotenv:dump prod
859+
.. code-block:: yaml
860+
861+
# config/services.yaml
862+
services:
863+
Symfony\Component\Dotenv\Command\DotenvDumpCommand: ~
864+
865+
Then, run the command:
866+
867+
.. code-block:: terminal
868+
869+
# parses ALL .env files and dumps their final values to .env.local.php
870+
$ php bin/console dotenv:dump prod
861871
862872
After running this command, Symfony will load the ``.env.local.php`` file to
863873
get the environment variables and will not spend time parsing the ``.env`` files.

0 commit comments

Comments
 (0)
0