2017-02-21 79 views
2

我正在開發一個具有常規依賴關係和一個dev依賴關係的包庫。 Composer recommends to not include the composer.lock file for libraries,所以這裏是composer.json爲什麼作曲家安裝--no-dev不起作用?

{ 
    "name": "myself/mypackage", 
    "require": { 
     "php": ">=5.6", 
     "nesbot/carbon": "~1.20" 
    }, 
    "require-dev": { 
     "phpunit/phpunit": "^6.0" 
    } 
} 

我想這是與運行PHP 5.6的應用程序兼容使用,我想使用最新的PHPUnit的測試工具需要PHP開發它7.

在特拉維斯連續集成測試服務器,我有運行在PHP> 7的PHPUnit測試和掉毛腳本構建矩陣:

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部分。

回答

5

儘管recommendation,這是因爲您沒有composer.lock文件,實際上是a requested feature

首先,它試圖解決所有依賴關係。如果失敗,它會中止。接下來,它運行實際安裝,並在那時忽略dev的依賴關係。你的問題是它無法通過解決問題的第一步。所以這並不是說它忽略了--no-dev國旗,它從來沒有做過這麼多。

選項1

如果包含composer.lock文件,然後將其跳過依賴解析和去直接安裝那時它會跳過開發的依賴。

選項2

既然你不包括圖書館,而是一個可執行的工具,那麼,而不是戰鬥其他開發工具之間的潛在衝突依賴你以後可能會包括剛拉出來的作曲家完全和使用phive (The PHAR Installation and Verification Environment)