phpunit / phpunit ^ 6.2安装失败

时间:2017-07-17 14:10:12

标签: php phpunit composer-php

我跑的时候

composer require --dev phpunit/phpunit

我收到以下消息:

composer require --dev phpunit/phpunit
Using version ^6.2 for phpunit/phpunit
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Installation request for sebastian/object-enumerator (locked at 2.0.1) -> satisfiable by sebastian/object-enumerator[2.0.1].
- phpunit/phpunit 6.2.0 requires sebastian/object-enumerator ^3.0.2 -> satisfiable by sebastian/object-enumerator[3.0.2].
- phpunit/phpunit 6.2.1 requires sebastian/object-enumerator ^3.0.2 -> satisfiable by sebastian/object-enumerator[3.0.2].
- phpunit/phpunit 6.2.2 requires sebastian/object-enumerator ^3.0.2 -> satisfiable by sebastian/object-enumerator[3.0.2].
- phpunit/phpunit 6.2.3 requires sebastian/object-enumerator ^3.0.2 -> satisfiable by sebastian/object-enumerator[3.0.2].
- Conclusion: don't install sebastian/object-enumerator 3.0.2
- Installation request for phpunit/phpunit ^6.2 -> satisfiable by phpunit/phpunit[6.2.0, 6.2.1, 6.2.2, 6.2.3].

Installation failed, reverting ./composer.json to its original content.

这是我的作曲家json文件:

"require": {
  "php": "^7.0",
  "laravel/framework": "^5.4",
  "guzzlehttp/guzzle": "^6.3",
  "symfony/psr-http-message-bridge": "^1.0",
  "mcamara/laravel-localization": "^1.2",
  "laravelcollective/html": "^5.4",
  "laravel/socialite": "^3.0",
  "yajra/laravel-datatables-oracle": "^7.9"
},
"require-dev": {
  "fzaninotto/faker": "^1.6",
  "symfony/css-selector": "^3.3",
  "symfony/dom-crawler": "^3.3"
}

我试图从上面的5.4版获得并且总是得到类似的错误,但是对于其他依赖,唯一可行的版本是5.0

2 个答案:

答案 0 :(得分:12)

运行

$ composer require --dev phpunit/phpunit --update-with-dependencies

请参阅https://getcomposer.org/doc/03-cli.md#require

  

- update-with-dependencies :还更新新所需包的依赖关系。

注意在这种情况下删除composer.lock并不是最好的主意,因为它可能会导致在其他地方破坏代码的依赖关系。您实际上只想一次更新特定的依赖项,而不是一次更新所有依赖项。

答案 1 :(得分:2)

如果您使用composer update文件和composer.lock文件夹运行vendor,则Composer会在更新前将已安装的版本转换为帐户。

确保将锁定文件提交到项目存储库中,以便能够恢复当前版本。然后尝试另一次更新,但在此之前删除锁定文件和供应商文件夹。

我的经验是,这样的更新不会受到已安装版本的影响,这可能会阻止必要的更新。

调试依赖项的另一个选项是使用composer why-not phpunit/phpunit 6.2.0(使用您知道存在的显式版本 - 没有版本,命令的输出没有意义)。 Composer将为您提供阻止更新的依赖项列表,供您进一步调查。