无法使用 composer 安装 phpunit 和 phpunit-selenium
Posted
技术标签:
【中文标题】无法使用 composer 安装 phpunit 和 phpunit-selenium【英文标题】:Can't install phpunit and phpunit-selenium with composer 【发布时间】:2017-11-10 14:27:45 【问题描述】:我正在尝试遵循本指南https://www.sitepoint.com/using-selenium-with-phpunit/,以便可以使用 PHP 自动化 Chrome。我已经在 Python 中完成了这项工作,但我对 PHP 更加熟悉,所以我认为它会更容易(也许我错了......)
无论如何,当我跑步时
composer require --dev phpunit/phpunit
composer require --dev phpunit/phpunit-selenium
我从作曲家那里得到了大量关于它们如何依赖于不可能同时完成的不同事情的输出(我想,我在这里也可能是错的)。我的输出:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- phpunit/phpunit-selenium 3.0.3 requires phpunit/phpunit ~5.0 -> satisfiable by phpunit/phpunit[5.0.0, 5.0.1, 5.0.10, 5.0.2, 5.0.3, 5.0.4, 5.0.5, 5.0.6, 5.0.7, 5.0.8, 5.0.9, 5.0.x-dev, 5.1.0, 5.1.1, 5.1.2, 5.1.3, 5.1.4, 5.1.5, 5.1.6, 5.1.7, 5.1.x-dev, 5.2.0, 5.2.1, 5.2.10, 5.2.11, 5.2.12, 5.2.2, 5.2.3, 5.2.4, 5.2.5, 5.2.6, 5.2.7, 5.2.8, 5.2.9, 5.2.x-dev, 5.3.0, 5.3.1, 5.3.2, 5.3.3, 5.3.4, 5.3.5, 5.3.x-dev, 5.4.0, 5.4.1, 5.4.2, 5.4.3, 5.4.4, 5.4.5, 5.4.6, 5.4.7, 5.4.8, 5.4.x-dev, 5.5.0, 5.5.1, 5.5.2, 5.5.3, 5.5.4, 5.5.5, 5.5.6, 5.5.7, 5.5.x-dev, 5.6.0, 5.6.1, 5.6.2, 5.6.3, 5.6.4, 5.6.5, 5.6.6, 5.6.7, 5.6.8, 5.6.x-dev, 5.7.0, 5.7.1, 5.7.10, 5.7.11, 5.7.12, 5.7.13, 5.7.14, 5.7.15, 5.7.16, 5.7.17, 5.7.18, 5.7.19, 5.7.2, 5.7.20, 5.7.3, 5.7.4, 5.7.5, 5.7.6, 5.7.7, 5.7.8, 5.7.9, 5.7.x-dev] but these conflict with your requirements or minimum-stability.
- phpunit/phpunit-selenium 3.0.2 requires phpunit/phpunit ~5.0 -> satisfiable by phpunit/phpunit[5.0.0, 5.0.1, 5.0.10, 5.0.2, 5.0.3, 5.0.4, 5.0.5, 5.0.6, 5.0.7, 5.0.8, 5.0.9, 5.0.x-dev, 5.1.0, 5.1.1, 5.1.2, 5.1.3, 5.1.4, 5.1.5, 5.1.6, 5.1.7, 5.1.x-dev, 5.2.0, 5.2.1, 5.2.10, 5.2.11, 5.2.12, 5.2.2, 5.2.3, 5.2.4, 5.2.5, 5.2.6, 5.2.7, 5.2.8, 5.2.9, 5.2.x-dev, 5.3.0, 5.3.1, 5.3.2, 5.3.3, 5.3.4, 5.3.5, 5.3.x-dev, 5.4.0, 5.4.1, 5.4.2, 5.4.3, 5.4.4, 5.4.5, 5.4.6, 5.4.7, 5.4.8, 5.4.x-dev, 5.5.0, 5.5.1, 5.5.2, 5.5.3, 5.5.4, 5.5.5, 5.5.6, 5.5.7, 5.5.x-dev, 5.6.0, 5.6.1, 5.6.2, 5.6.3, 5.6.4, 5.6.5, 5.6.6, 5.6.7, 5.6.8, 5.6.x-dev, 5.7.0, 5.7.1, 5.7.10, 5.7.11, 5.7.12, 5.7.13, 5.7.14, 5.7.15, 5.7.16, 5.7.17, 5.7.18, 5.7.19, 5.7.2, 5.7.20, 5.7.3, 5.7.4, 5.7.5, 5.7.6, 5.7.7, 5.7.8, 5.7.9, 5.7.x-dev] but these conflict with your requirements or minimum-stability.
- phpunit/phpunit-selenium 3.0.1 requires phpunit/phpunit ~5.0 -> satisfiable by phpunit/phpunit[5.0.0, 5.0.1, 5.0.10, 5.0.2, 5.0.3, 5.0.4, 5.0.5, 5.0.6, 5.0.7, 5.0.8, 5.0.9, 5.0.x-dev, 5.1.0, 5.1.1, 5.1.2, 5.1.3, 5.1.4, 5.1.5, 5.1.6, 5.1.7, 5.1.x-dev, 5.2.0, 5.2.1, 5.2.10, 5.2.11, 5.2.12, 5.2.2, 5.2.3, 5.2.4, 5.2.5, 5.2.6, 5.2.7, 5.2.8, 5.2.9, 5.2.x-dev, 5.3.0, 5.3.1, 5.3.2, 5.3.3, 5.3.4, 5.3.5, 5.3.x-dev, 5.4.0, 5.4.1, 5.4.2, 5.4.3, 5.4.4, 5.4.5, 5.4.6, 5.4.7, 5.4.8, 5.4.x-dev, 5.5.0, 5.5.1, 5.5.2, 5.5.3, 5.5.4, 5.5.5, 5.5.6, 5.5.7, 5.5.x-dev, 5.6.0, 5.6.1, 5.6.2, 5.6.3, 5.6.4, 5.6.5, 5.6.6, 5.6.7, 5.6.8, 5.6.x-dev, 5.7.0, 5.7.1, 5.7.10, 5.7.11, 5.7.12, 5.7.13, 5.7.14, 5.7.15, 5.7.16, 5.7.17, 5.7.18, 5.7.19, 5.7.2, 5.7.20, 5.7.3, 5.7.4, 5.7.5, 5.7.6, 5.7.7, 5.7.8, 5.7.9, 5.7.x-dev] but these conflict with your requirements or minimum-stability.
- phpunit/phpunit-selenium 3.0.0 requires phpunit/phpunit ~5 -> satisfiable by phpunit/phpunit[5.0.0, 5.0.1, 5.0.10, 5.0.2, 5.0.3, 5.0.4, 5.0.5, 5.0.6, 5.0.7, 5.0.8, 5.0.9, 5.0.x-dev, 5.1.0, 5.1.1, 5.1.2, 5.1.3, 5.1.4, 5.1.5, 5.1.6, 5.1.7, 5.1.x-dev, 5.2.0, 5.2.1, 5.2.10, 5.2.11, 5.2.12, 5.2.2, 5.2.3, 5.2.4, 5.2.5, 5.2.6, 5.2.7, 5.2.8, 5.2.9, 5.2.x-dev, 5.3.0, 5.3.1, 5.3.2, 5.3.3, 5.3.4, 5.3.5, 5.3.x-dev, 5.4.0, 5.4.1, 5.4.2, 5.4.3, 5.4.4, 5.4.5, 5.4.6, 5.4.7, 5.4.8, 5.4.x-dev, 5.5.0, 5.5.1, 5.5.2, 5.5.3, 5.5.4, 5.5.5, 5.5.6, 5.5.7, 5.5.x-dev, 5.6.0, 5.6.1, 5.6.2, 5.6.3, 5.6.4, 5.6.5, 5.6.6, 5.6.7, 5.6.8, 5.6.x-dev, 5.7.0, 5.7.1, 5.7.10, 5.7.11, 5.7.12, 5.7.13, 5.7.14, 5.7.15, 5.7.16, 5.7.17, 5.7.18, 5.7.19, 5.7.2, 5.7.20, 5.7.3, 5.7.4, 5.7.5, 5.7.6, 5.7.7, 5.7.8, 5.7.9, 5.7.x-dev] but these conflict with your requirements or minimum-stability.
- Installation request for phpunit/phpunit-selenium ^3.0 -> satisfiable by phpunit/phpunit-selenium[3.0.0, 3.0.1, 3.0.2, 3.0.3].
Installation failed, reverting ./composer.json to its original content.
这是我的composer.json
内容
"require":
"giggsey/libphonenumber-for-php": "~7.0",
"firephp/firephp-core": "0.4.0",
"aws/aws-sdk-php": "^3.3",
"jdorn/sql-formatter": "^1.2",
"piwik/device-detector": "3.5.0",
"doctrine/cache": "1.6.0",
"php-console/php-console": "~3.0",
"gabrielbull/ups-api": "^0.7.3",
"google/apiclient": "^2.0",
"jeremeamia/superclosure": "^2.3",
"commerceguys/addressing": "^0.8.4",
"arcreative/php-address-format": "^0.0.2",
"commerceguys/intl": "^0.7.4",
"ramsey/uuid": "^3.6",
"neitanod/forceutf8": "^2.0",
"facebook/webdriver": "^1.4",
"phpunit/phpunit": "^6.2"
【问题讨论】:
【参考方案1】:composer require --dev phpunit/phpunit
这将安装最新的 PHPUnit,当前版本为 6.x。
composer require --dev phpunit/phpunit-selenium
然后这将尝试安装 selenium 扩展,因为它需要 PHPUnit 5.x,所以无法安装,因为您可以看到读取的输出为“问题 1”。
解决方案:明确要求 PHPUnit 5,然后要求 phpunit-selenium。
附带说明:您提供了错误的composer.json
,它无法通过您提到的命令创建。它应该在 "require-dev"
下列出 PHPUnit。
【讨论】:
看起来我只是在第一次安装时省略了--dev
标志,这就是它不在正确位置的原因。我必须查找如何要求特定版本,所以我运行的命令(删除phpunit
后)是php composer.phar require --dev phpunit/phpunit "^5"
,它一切正常!以上是关于无法使用 composer 安装 phpunit 和 phpunit-selenium的主要内容,如果未能解决你的问题,请参考以下文章
不推荐使用 composer require-dev 安装 phpunit?
Composer 安装的 PHPUnit 二进制文件使用系统提供的 ResultPrinter 并失败