我正在开发一个具有常规依赖关系和一个DEV依赖性的软件包库。作曲家建议不包括库的composer.lock
文件,因此是composer.json
{
"name": "myself/mypackage",
"require": {
"php": ">=5.6",
"nesbot/carbon": "~1.20"
},
"require-dev": {
"phpunit/phpunit": "^6.0"
}
}
我希望与运行PHP 5.6的应用程序兼容,并且我想使用需要PHP 7的最新PHPUnit测试工具来开发它。
在Travis连续集成测试服务器上,我有一个构建矩阵,该矩阵在PHP&GT上运行Phpunit测试;7和一个绒毛脚本:
composer install
./lint-php.bash
phpunit
和php<7,只需提示源代码:
composer install --no-dev
./lint-php.bash
但是,它失败了,因为它忽略了 --no-dev
标志,并试图安装dev依赖关系。
Your requirements could not be resolved to an installable set of packages. Problem 1 - phpunit/phpunit 6.0.7 requires php ^7.0 -> your PHP version (5.6.5) does not satisfy that requirement. - phpunit/phpunit 6.0.6 requires php ^7.0 -> your PHP version (5.6.5) does not satisfy that requirement. - phpunit/phpunit 6.0.5 requires php ^7.0 -> your PHP version (5.6.5) does not satisfy that requirement. - phpunit/phpunit 6.0.4 requires php ^7.0 -> your PHP version (5.6.5) does not satisfy that requirement. - phpunit/phpunit 6.0.3 requires php ^7.0 -> your PHP version (5.6.5) does not satisfy that requirement. - phpunit/phpunit 6.0.2 requires php ^7.0 -> your PHP version (5.6.5) does not satisfy that requirement. - phpunit/phpunit 6.0.1 requires php ^7.0 -> your PHP version (5.6.5) does not satisfy that requirement. - phpunit/phpunit 6.0.0 requires php ^7.0 -> your PHP version (5.6.5) does not satisfy that requirement. - Installation request for phpunit/phpunit ^6.0 -> satisfiable by phpunit/phpunit[6.0.0, 6.0.1, 6.0.2, 6.0.3, 6.0.4, 6.0.5, 6.0.6, 6.0.7].
为什么忽略--no-dev
标志?我只希望它安装我的常规依赖项并忽略require-dev
部分。
尽管有建议,这是因为您没有composer.lock
文件,实际上是一个请求的功能。
首先,它试图解决所有依赖关系。如果这失败了,它会退出。接下来,它运行实际的安装,当时忽略了Dev依赖项。您的问题是它无法通过解决方案的第一步。因此,这并不是说它忽略了--no-dev
标志,而是从来没有走那么远。
选项1
如果包含一个composer.lock
文件,则它会跳过依赖项分辨率,然后直接安装在此时,它将跳过Dev依赖项。
选项2
由于您不包括库,而是一个可执行的工具,因此,您可能会完全将其包含在其他Dev工具之间的潜在依赖关系冲突,而只需将其完全从作曲家中撤出并使用Phive(Phar安装和PHAR安装和验证环境)。