Adds support for .env configuration files to Magento 2. Variables in the .env file are used to fill in app/etc/env.php
variables. This file can be added to source control when using this package. I think having more than one environment file is weird.
Credits to this package which inspired me to make this package.
composer require justbetter/dotenv
- Copy the
.env.example
example file toapp/etc/.env
, or..env
and fill in your environment variables. - Replace the
env.php
with this one and commit it to source control. bin/magento setup:upgrade
You can override specific environments with the APP_ENV variable in the dot env filename. example. Copy the file to app/etc/
and modify for any specified environment.
You can also load additional .env files by defining them in LOAD_BEFORE
(allowing the values in these files to be overridden) or LOAD_AFTER
(allowing the values in these files to override all others) with your extra .env files you would like to load.
Because of the Writer class of magento 2 the env.php
get rewrited every time. I disabled this functionality because the env.php
file is not static. The cache types are not reset every time when you run bin/magento setup:upgrade
.
The module is tested on Magento version 2.4.x
Please create a issue or a pull request.
We’re a innovative development agency from The Netherlands building awesome websites, webshops and web applications with Laravel and Magento. Check out our website justbetter.nl and our open source projects.