承接 yannoff/composer-dotenv-handler 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

yannoff/composer-dotenv-handler

Composer 安装命令:

composer require yannoff/composer-dotenv-handler

包简介

Composer script to generate .env file against .env.dist template

README 文档

README

Latest Stable Version Total Downloads License

Composer script to handle .env file maintenance, based upon the concept of the popular incenteev/composer-parameter-handler package.

Usage

First you must require the package:

$ composer require yannoff/composer-dotenv-handler

Then, set up your composer.json accordingly, as in the following example:

...
    "scripts": {
        "post-install-cmd": "Yannoff\\DotenvHandler\\ScriptHandler::updateEnvFile"
    }
...

Advanced options

Options may be passed via the extra section of the composer.json :

    "extra": {
        "yannoff-dotenv-handler": {
            // options here
        }
    }

Available options

Name Default value Description
file .env The name of the auto-generated dotenv file
dist-file .env.dist The name of the template file (the dist file)
keep-outdated true Keep values in the env file that are not anymore in the dist file
behavior normal If set to flex, enable support for Symfony Flex applications (see next section for details)

Symfony Flex Behavior

As of November 2018, the guys at Symfony decided to change radically how dotenv files are handled in symfony applications.

A local temporary workaround could be to modify the composer.json extra section as follow:

    "extra": {
        "yannoff-dotenv-handler": {
            "file": ".env.local",
            "dist-file": ".env"
        }
    }

Anyway this is not an acceptable solution, indeed the dotenv file name may vary from one deploy environment to another (test, staging, prod...): the composer.json can't be committed as is.

So here comes the behavior option:

    "extra": {
        "yannoff-dotenv-handler": {
            "behavior": "flex"
        }
    }

When in flex behavior mode, the script will build the dotenv file name automatically, based upon either the APP_ENV or ENV (in this order of preference) environment variable (will use local as default value, if not set) at runtime.

For example, issuing the following command in a terminal:

$ /usr/bin/env ENV=staging composer install

would result in having the following config values:

  • dist-file : .env
  • file : .env.staging

Licence

Licensed under the MIT Licence.

统计信息

  • 总下载量: 2.2k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-02-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固