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+ environment name +
.env.test.local). These are the environment-specific settings overridden locally on your machine.
.env.local. Used for overriding values on your local machine. This file is loaded for all environments except
.env+ environment name (
.env.test). These are the files that define environment-specific settings. Useful for example to override settings like the database connection for tests.
.env. Same file as used by current Symfony apps.
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.