Skip to content

Prioritize the dump-env Composer command #18890

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 29 additions & 19 deletions configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -831,33 +831,43 @@ In production, the ``.env`` files are also parsed and loaded on each request. So
the easiest way to define env vars is by creating a ``.env.local`` file on your
production server(s) with your production values.

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

.. code-block:: yaml
.. code-block:: terminal

# config/services.yaml
services:
Symfony\Component\Dotenv\Command\DotenvDumpCommand:
- '%kernel.project_dir%/.env'
- '%kernel.environment%'
# parses ALL .env files and dumps their final values to .env.local.php
$ composer dump-env prod

In PHP >= 8, you can remove the two arguments when autoconfiguration is enabled
(which is the default):
.. sidebar:: Dumping Environment Variables without Composer

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

# config/services.yaml
services:
Symfony\Component\Dotenv\Command\DotenvDumpCommand: ~
.. code-block:: yaml

Then, run the command:
# config/services.yaml
services:
Symfony\Component\Dotenv\Command\DotenvDumpCommand:
- '%kernel.project_dir%/.env'
- '%kernel.environment%'

.. code-block:: terminal
In PHP >= 8, you can remove the two arguments when autoconfiguration is enabled
(which is the default):

# parses ALL .env files and dumps their final values to .env.local.php
$ php bin/console dotenv:dump prod
.. code-block:: yaml

# config/services.yaml
services:
Symfony\Component\Dotenv\Command\DotenvDumpCommand: ~

Then, run the command:

.. code-block:: terminal

# parses ALL .env files and dumps their final values to .env.local.php
$ php bin/console dotenv:dump prod

After running this command, Symfony will load the ``.env.local.php`` file to
get the environment variables and will not spend time parsing the ``.env`` files.
Expand Down