@@ -844,33 +844,43 @@ In production, the ``.env`` files are also parsed and loaded on each request. So
844
844
the easiest way to define env vars is by creating a ``.env.local `` file on your
845
845
production server(s) with your production values.
846
846
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:
850
848
851
- .. code-block :: yaml
849
+ .. code-block :: terminal
852
850
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
858
853
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
861
855
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:
863
860
864
- # config/services.yaml
865
- services :
866
- Symfony\Component\Dotenv\Command\DotenvDumpCommand : ~
861
+ .. code-block :: yaml
867
862
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%'
869
868
870
- .. code-block :: terminal
869
+ In PHP >= 8, you can remove the two arguments when autoconfiguration is enabled
870
+ (which is the default):
871
871
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
874
884
875
885
After running this command, Symfony will load the ``.env.local.php `` file to
876
886
get the environment variables and will not spend time parsing the ``.env `` files.
0 commit comments