diff --git a/configuration.rst b/configuration.rst index 5e62421dd6c..a5662985dde 100644 --- a/configuration.rst +++ b/configuration.rst @@ -772,13 +772,30 @@ In production, the ``.env`` files are also parsed and loaded on each request. So the easiest way to define env vars is by deploying a ``.env.local`` file to your production server(s) with your production values. -To improve performance, you can optionally run the ``dump-env`` command (available -in :ref:`Symfony Flex ` 1.2 or later): +To improve performance, you can optionally run the ``dotenv:dump`` command (available +in :ref:`Symfony Flex ` 1.2 or later). The command is not registered by default. +In order to enable it, you must add it to their services.yaml file: + +.. code-block:: yaml + + services: + Symfony\Component\Dotenv\Command\DotenvDumpCommand: + - '%kernel.project_dir%/.env' + - '%kernel.environment%' + +On PHP >= 8, the two arguments can be removed when autoconfiguration is enabled (which is the default): + +.. code-block:: yaml + + services: + Symfony\Component\Dotenv\Command\DotenvDumpCommand: ~ + +Running command: .. code-block:: terminal # parses ALL .env files and dumps their final values to .env.local.php - $ composer dump-env prod + $ 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. diff --git a/deployment.rst b/deployment.rst index 1de29ae5b16..f61f8e1509b 100644 --- a/deployment.rst +++ b/deployment.rst @@ -164,14 +164,14 @@ most natural in your hosting environment. .. code-block:: terminal - $ composer dump-env prod + $ php bin/console dotenv:dump prod - The generated file will contain all the configuration stored in ``.env``. If you + The generated file will contain all the configurations stored in ``.env``. If you want to rely only on environment variables, generate one without any values using: .. code-block:: terminal - $ composer dump-env prod --empty + $ php bin/console dotenv:dump prod --empty C) Install/Update your Vendors ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~