Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pr00xxy/magento2-dotenv
Magento 2 module that adds support for .env (dotenv) file configuration parsing
https://github.com/pr00xxy/magento2-dotenv
dotenv env environment-variables magento2 magento2-extension magento2-extension-free magento2-module magento2-plugin
Last synced: about 1 month ago
JSON representation
Magento 2 module that adds support for .env (dotenv) file configuration parsing
- Host: GitHub
- URL: https://github.com/pr00xxy/magento2-dotenv
- Owner: Pr00xxy
- Created: 2020-02-27T20:08:30.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-08-06T19:29:55.000Z (over 4 years ago)
- Last Synced: 2024-11-07T10:55:16.278Z (about 2 months ago)
- Topics: dotenv, env, environment-variables, magento2, magento2-extension, magento2-extension-free, magento2-module, magento2-plugin
- Language: PHP
- Homepage:
- Size: 14.6 KB
- Stars: 9
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Magento 2 .env module
Adds support for .env configuration files to Magento 2.
This module was created because Magento [recommends](https://devdocs.magento.com/guides/v2.3/config-guide/prod/config-reference-var-name.html#how-to-use-environment-variables) injection of variables into $_ENV through the index.php file. I believe that is a stupid suggestion.
## Installation
Use [composer](https://getcomposer.org/) to install this.
```bash
composer require prooxxy/magento2-dotenv
```### Alternative installation
If you don't have the option to use composer it's possible to copy the root of this project into the `app/code/PrOOxxy/DotEnv` folder of your magento installation
Make sure the module is enable before start using
```bash
php bin/magento module:enable PrOOxxy_DotEnv
php bin/magento setup:upgrade
```## Features
This module does only one thing once installed.
It reads and parses any variables that is locate inside /app/etc/.env
and injects it into the global `$_ENV` arrayIt does this before Magento processes other environments variables.
It does override any preexisting variable with the same name.## Usage
1. Add .env into app/etc
The file must have chmod level 0644 or below
2. Follow the official devdocs [instructions](https://devdocs.magento.com/guides/v2.3/config-guide/deployment/pipeline/example/environment-variables.html#step-4-update-the-production-system) for how to create the env variable format
3. Add your newly formatted variables into the .env like so e.g`CONFIG__DEFAULT__SYSTEM__SMTP__HOST="8.8.8.8"`
4. Flush the config cache
```bash
php bin/magento cache:flush config
```## Compability
Magento 2 Open Source 2.3.x
Magento 2 Open Source 2.4.x
Magento 2 Commerce 2.3.x
Magento 2 Commerce 2.4.x## License
[MIT](https://choosealicense.com/licenses/mit/)