bangpound/composer-dotenv

There is no license information available for the latest version (dev-master) of this package.

Load environment variables from `.env` when Composer runs

Installs: 29 455

Dependents: 0

Suggesters: 0

Security: 0

Stars: 7

Watchers: 3

Forks: 0

Open Issues: 1

Type:composer-plugin

dev-master / 1.0.x-dev 2016-08-21 23:23 UTC

This package is auto-updated.

Last update: 2024-10-12 03:26:11 UTC


README

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"
        }
    }
}