├── .gitignore ├── LICENSE ├── MagentoDotenv.php ├── README.md ├── autoload.php ├── composer.json ├── composer.lock └── dist └── app └── dotenv.php /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | /vendor -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Benjamin Calef 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /MagentoDotenv.php: -------------------------------------------------------------------------------- 1 | usePutEnv($usePutEnv); 79 | $dotenv->loadEnv(ROOT_DIRECTORY . $envFilePath . self::ENV_FILE); 80 | 81 | return $dotenv; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Magento Dotenv 2 | 3 | Simple autoloader to integrate Symfony Dotenv component to Magento2. 4 | The implementation can be found under path ``app/dotenv.php`` and can be configured safely for your needs. 5 | 6 | # Compatibility 7 | 8 | | Magento Dotenv | v1.* | v2.* | 9 | |----------------|------|-------------| 10 | | Symfony Dotenv | ^5.0 | ^5.4 / ^6.0 | 11 | | PHP version | ^7.0 | ^8.0 | 12 | 13 | 14 | # Installation 15 | 16 | ``` 17 | composer require zepgram/magento-dotenv 18 | ``` 19 | 20 | # How to 21 | 22 | You can use it similar way as a Symfony project: 23 | 1. If .env exists, it is loaded first. In case there's no .env file but a .env.dist, this one will be loaded instead. 24 | 1. If one of the previously mentioned files contains the APP_ENV variable, the variable is populated and used to load environment-specific files hereafter. If APP_ENV is not defined in either of the previously mentioned files, dev is assumed for APP_ENV and populated by default. 25 | 1. If there's a .env.local representing general local environment variables it's loaded now. 26 | 1. If there's a .env.$env.local file, this one is loaded. Otherwise, it falls back to .env.$env. 27 | 28 | You can freely edit ``app/dotenv.php``: this file will be not updated. 29 | 30 | For more information you can follow the documentation: 31 | https://symfony.com/doc/current/components/dotenv.html 32 | -------------------------------------------------------------------------------- /autoload.php: -------------------------------------------------------------------------------- 1 | getFileName(), 3); 10 | define('ROOT_DIRECTORY', $rootDirectory . DIRECTORY_SEPARATOR); 11 | 12 | MagentoDotenv::init(); 13 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "zepgram/magento-dotenv", 3 | "description": "Simple autoloader to integrate the Symfony Dotenv component into Magento2", 4 | "keywords": ["magento2", "environment", "env", "dotenv"], 5 | "type": "magento2-component", 6 | "version": "2.0.3", 7 | "authors":[ 8 | { 9 | "name": "Benjamin Calef", 10 | "email": "zepgram@gmail.com" 11 | } 12 | ], 13 | "license": "MIT", 14 | "require": { 15 | "php": ">=8.0.2", 16 | "symfony/dotenv": "^5.4|^6.0" 17 | }, 18 | "autoload": { 19 | "files": [ 20 | "autoload.php" 21 | ], 22 | "psr-4": { 23 | "Zepgram\\Component\\MagentoDotenv\\": "" 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "ab04ddb92c0158f546a1758cb6f7ebd2", 8 | "packages": [ 9 | { 10 | "name": "symfony/dotenv", 11 | "version": "v6.0.5", 12 | "source": { 13 | "type": "git", 14 | "url": "https://github.com/symfony/dotenv.git", 15 | "reference": "1c2288fdfd0787288cd04b9868f879f2212159c4" 16 | }, 17 | "dist": { 18 | "type": "zip", 19 | "url": "https://api.github.com/repos/symfony/dotenv/zipball/1c2288fdfd0787288cd04b9868f879f2212159c4", 20 | "reference": "1c2288fdfd0787288cd04b9868f879f2212159c4", 21 | "shasum": "" 22 | }, 23 | "require": { 24 | "php": ">=8.0.2" 25 | }, 26 | "require-dev": { 27 | "symfony/console": "^5.4|^6.0", 28 | "symfony/process": "^5.4|^6.0" 29 | }, 30 | "type": "library", 31 | "autoload": { 32 | "psr-4": { 33 | "Symfony\\Component\\Dotenv\\": "" 34 | }, 35 | "exclude-from-classmap": [ 36 | "/Tests/" 37 | ] 38 | }, 39 | "notification-url": "https://packagist.org/downloads/", 40 | "license": [ 41 | "MIT" 42 | ], 43 | "authors": [ 44 | { 45 | "name": "Fabien Potencier", 46 | "email": "fabien@symfony.com" 47 | }, 48 | { 49 | "name": "Symfony Community", 50 | "homepage": "https://symfony.com/contributors" 51 | } 52 | ], 53 | "description": "Registers environment variables from a .env file", 54 | "homepage": "https://symfony.com", 55 | "keywords": [ 56 | "dotenv", 57 | "env", 58 | "environment" 59 | ], 60 | "support": { 61 | "source": "https://github.com/symfony/dotenv/tree/v6.0.5" 62 | }, 63 | "funding": [ 64 | { 65 | "url": "https://symfony.com/sponsor", 66 | "type": "custom" 67 | }, 68 | { 69 | "url": "https://github.com/fabpot", 70 | "type": "github" 71 | }, 72 | { 73 | "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", 74 | "type": "tidelift" 75 | } 76 | ], 77 | "time": "2022-02-21T17:15:17+00:00" 78 | } 79 | ], 80 | "packages-dev": [], 81 | "aliases": [], 82 | "minimum-stability": "stable", 83 | "stability-flags": [], 84 | "prefer-stable": false, 85 | "prefer-lowest": false, 86 | "platform": { 87 | "php": ">=8.0.2" 88 | }, 89 | "platform-dev": [], 90 | "plugin-api-version": "2.3.0" 91 | } 92 | -------------------------------------------------------------------------------- /dist/app/dotenv.php: -------------------------------------------------------------------------------- 1 |