Skip to content

bangpound/composer-dotenv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Composer Dotenv

Whenever Composer is activated in a project with a .env file, this plugin will use the vlucas/phpdotenv library to load this configuration file into the PHP envrionment.

This plugin works well with incenteev/composer-parameter-handler which allows you to map environment variables to parameters. This plugin runs when composer is activated, and ParameterHandler finds that configuration in the environment after your dependencies have been installed or updated.

Example

If your .env file contains:

SECRET_FOR_ME="123456"

And your composer.json file contains:

{
    "require": {
        "incenteev/composer-parameter-handler": "~2.0",
        "bangpound/composer-dotenv": "~1.0@dev"
    },
    "extra": {
        "incenteev-parameters": {
            "file": "app/config/parameters.yml",
            "env-map": {
                "secret": "SECRET_FOR_ME"
            }
        }
    },
    "scripts": {
        "post-install-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters"
        ],
        "post-update-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters"
        ]
    },
}

Then after running composer update or install, your app/config/parameters.yml will contain:

# This file is auto-generated during the composer install
parameters:
    secret: 123456

Settings

In the extra property of the root repository, change these values as necessary:

{
    "extra": {
        "dotenv": {
            "path": ".",
            "file": ".env"
        }
    }
}

About

Load environment variables from `.env` when Composer runs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages