@@ -831,33 +831,43 @@ In production, the ``.env`` files are also parsed and loaded on each request. So
831
831
the easiest way to define env vars is by creating a ``.env.local `` file on your
832
832
production server(s) with your production values.
833
833
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:
837
835
838
- .. code-block :: yaml
836
+ .. code-block :: terminal
839
837
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
845
840
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
848
842
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:
850
847
851
- # config/services.yaml
852
- services :
853
- Symfony\Component\Dotenv\Command\DotenvDumpCommand : ~
848
+ .. code-block :: yaml
854
849
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%'
856
855
857
- .. code-block :: terminal
856
+ In PHP >= 8, you can remove the two arguments when autoconfiguration is enabled
857
+ (which is the default):
858
858
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
861
871
862
872
After running this command, Symfony will load the ``.env.local.php `` file to
863
873
get the environment variables and will not spend time parsing the ``.env `` files.
0 commit comments