Composer安装说在生产环境中出现以下错误

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Composer安装说在生产环境中出现以下错误相关的知识,希望对你有一定的参考价值。

当我尝试在prod中安装composer时,我在安装composer时遇到以下错误,任何人都可以建议我帮忙。谢谢。

 Problem 1
- Installation request for doctrine/annotations v1.5.0 -> satisfiable by doctrine/annotations[v1.5.0].
- doctrine/annotations v1.5.0 requires php ^7.1 -> your PHP version (7.0.22) does not satisfy that requirement.
  Problem 2
- Installation request for doctrine/cache v1.7.1 -> satisfiable by doctrine/cache[v1.7.1].
- doctrine/cache v1.7.1 requires php ~7.1 -> your PHP version (7.0.22) does not satisfy that requirement.
 Problem 3
- Installation request for doctrine/collections v1.5.0 -> satisfiable by doctrine/collections[v1.5.0].
- doctrine/collections v1.5.0 requires php ^7.1 -> your PHP version (7.0.22) does not satisfy that requirement.
 Problem 4
- Installation request for doctrine/common v2.8.1 -> satisfiable by doctrine/common[v2.8.1].
- doctrine/common v2.8.1 requires php ~7.1 -> your PHP version (7.0.22) does not satisfy that requirement.
 Problem 5
- Installation request for doctrine/dbal v2.6.2 -> satisfiable by doctrine/dbal[v2.6.2].
- doctrine/dbal v2.6.2 requires php ^7.1 -> your PHP version (7.0.22) does not satisfy that requirement.
Problem 6
- Installation request for doctrine/instantiator 1.1.0 -> satisfiable by doctrine/instantiator[1.1.0].
- doctrine/instantiator 1.1.0 requires php ^7.1 -> your PHP version (7.0.22) does not satisfy that requirement.
 Problem 7
- doctrine/instantiator 1.1.0 requires php ^7.1 -> your PHP version (7.0.22) does not satisfy that requirement.
- phpunit/phpunit-mock-objects 3.4.4 requires doctrine/instantiator ^1.0.2 -> satisfiable by doctrine/instantiator[1.1.0].
- Installation request for phpunit/phpunit-mock-objects 3.4.4 -> satisfiable by phpunit/phpunit-mock-objects[3.4.4].
答案

你的composer.lock是在运行PHP7.1的计算机上制作的,但是你的prod服务器运行的是7.0.22,或者你对(我猜)教条的版本限制太高了。要绕过第一个,将其添加到composer.json: ... "config": { "platform": { "php": "7.0.22" } } ...,运行composer update并检入生成的composer.lock文件。这样你就可以强迫composer为你的生产php版本选择包,它应该与你的开发版本(7.1)兼容。

另一答案

它比编辑composer.json更简单

例如,使用switch --ignore-platform-reqs和composer命令

composer update --ignore-platform-reqs

以上是关于Composer安装说在生产环境中出现以下错误的主要内容,如果未能解决你的问题,请参考以下文章

如何使用composer进行包管理更合适

如何使用composer进行包管理更合适

使用Composer安装阿里云短信失败

yii初体验composer安装+环境检测

如何使用 Composer 和 Symfony 解决错误 255 [关闭]

安装 Composer - 内部错误