New in Symfony 4.2: Define env vars per environment
Since the introduction of the DotEnv component in Symfony 3.3, we've been
working hard to improve the experience of using env vars to configure Symfony
apps. In Symfony 4.2, we've added a new
loadForEnv() method to allow you
define different env vars per environment.
Instead of creating a single
.env file at your project's root dir, you can
now create one or more env var files. The values for the env var are looked for
in the following order:
.env.$APP_ENV.local(don't commit this file to the repository) defines environment-specific overrides for your local machine;
.env.$APP_ENV(commit this file to the repository) and defines environment-specific defaults for all developers/machines;
.env.local(don't commit this file to the repository) overrides the main
.envconfig only for your local machine;
.env(commit this file to the repository) and defines the default values for the env vars used in the application.
We're working on a Symfony Flex recipe to bring this new feature into the full Symfony framework (see symfony/recipes #466). There's no need to change anything in your existing applications if you don't want to, but new projects will get the latest recipes versions, with the following changes:
.env(and committed to the shared repository).
New in Symfony 4.2: Define env vars per environment symfony.com/blog/new-in-symfony-4-2-define-env-vars-per-environmentTweet this
Comments are closed.
To ensure that comments stay relevant, they are closed for old posts.