一个项目在 Composer 中可以有两个以上的环境吗?


Can a project have more than two environments in Composer?

我有这个composer.json文件:

{
    "require": {
        "slim/slim": "2.4.*",
        "league/plates": "3.1.*",
        "michelf/php-markdown": "1.4.*",
        "zendframework/zendsearch": "dev-master"
    },
    "require-dev": {
        "phpunit/phpunit": "4.3.*",
        "maximebf/debugbar": "1.*",
        "openbuildings/phpunit-spiderling": "0.1.*",
        "jonnyw/php-phantomjs": "3.*"
    },
    ...
}

require块适合居住,require-dev的附加部门适合当地开发。但是,我发现在我的托管持续集成中,我不需要四个开发依赖项中的三个,因为它们没有被使用或已经可用。

我可以设置另一个块(例如 require-test ),或者我可以创建一个新的作曲家文件(例如 composer.test.json ) 对于这种情况?包含我不需要的东西没什么大不了的,但感觉有点多余。

听起来很麻烦,收效甚微。但是你可以设置环境变量,并且喜欢维护你的composer.json文件的副本。

By setting the COMPOSER env variable it is possible to set the filename of composer.json to something else.
For example:
    COMPOSER=composer-other.json php composer.phar install

链接