2017 © Pedro Peláez
 

composer-plugin composer-dotenv

Load environment variables from `.env` when Composer runs

image

bangpound/composer-dotenv

Load environment variables from `.env` when Composer runs

  • Monday, August 22, 2016
  • by bangpound
  • Repository
  • 1 Watchers
  • 5 Stars
  • 4,944 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 24 % Grown

The README.md

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., (*1)

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., (*2)

Example

If your .env file contains:, (*3)

SECRET_FOR_ME="123456"

And your composer.json file contains:, (*4)

{
    "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:, (*5)

# 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:, (*6)

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

The Versions

22/08 2016

dev-master

9999999-dev

Load environment variables from `.env` when Composer runs

  Sources   Download

The Requires

 

The Development Requires