Skip to content

Adds support for dot env configuration files to Magento 2.

License

Notifications You must be signed in to change notification settings

justbetter/magento2-dotenv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Magento 2 DotEnv loader

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

Credits to this package which inspired me to make this package.

Installation

  • composer require justbetter/dotenv
  • Copy the .env.example example file to app/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

Extending the environments

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.

Disabled the writer to env.php

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.

Compatibility

The module is tested on Magento version 2.4.x

Ideas, bugs or suggestions?

Please create a issue or a pull request.

About us

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.

License

MIT


JustBetter logo

About

Adds support for dot env configuration files to Magento 2.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages