如何解决 Laravel Composer 问题 - 您的要求无法解决为一组可安装的软件包

How to resolve Laravel Composer Issue - Your requirements could not be resolved to an installable set of packages

我正在使用 Windows 操作系统来 运行 PHP Laravel-8 应用程序。我的 Windows 本地系统中所有项目的 PHP 版本是 PHP-Version3.8。我本地系统中的所有 Laravel 项目都有 ("php": "^7.3|^8.0",)

但是,我从团队项目中发起了拉取请求,但它是 PHP-Version4。该项目还使用 Laravel-8 框架 ("php": "^7.4|^8.0",)

当我尝试 运行 在下载的项目上安装 composer 时,出现此错误:

Your lock file does not contain a compatible set of packages. Please run composer update.

Problem 1
  - Root composer.json requires php ^7.4|^8.0 but your PHP version (7.3.8) does not satisfy that requirement.
  Problem 2
  - lcobucci/clock is locked to version 2.0.0 and an update of this package was not requested.
  - lcobucci/clock 2.0.0 requires php ^7.4 || ^8.0 -> your php version (7.3.8) does not satisfy that requirement.
Problem 3
  - lcobucci/jwt is locked to version 4.0.3 and an update of this package was not requested.
  - lcobucci/jwt 4.0.3 requires php ^7.4 || ^8.0 -> your php version (7.3.8) does not satisfy that requirement.
Problem 4
  - lcobucci/jwt 4.0.3 requires php ^7.4 || ^8.0 -> your php version (7.3.8) does not satisfy that requirement.
  - league/oauth2-server 8.2.4 requires lcobucci/jwt ^3.4 || ^4.0 -> satisfiable by lcobucci/jwt[4.0.3].
  - league/oauth2-server is locked to version 8.2.4 and an update of this package was not requested.

然后我做composer update的时候报错就是这样:

Your requirements could not be resolved to an installable set of packages.

Problem 1
 - Root composer.json requires php ^7.4|^8.0 but your php version (7.3.8) does not satisfy that requirement.

所有项目都在使用 composer-2

如果我将我的本地系统升级到 PHPV-7.4,我将遇到部署项目的问题。

我该如何解决这个问题?

谢谢

打开您的 composer.json 文件并将版本替换为:

"require": {
    "php": "^7.3|^8.0",
},

你也可以使用这个命令:

composer install --ignore-platform-reqs

编辑:

如果这不起作用或导致更多问题,我建议您更新 PHP 版本,然后您必须为旧项目指定 PHP 版本并将它们绑定使用PHP 7.3 避免任何问题。在更新 PHP:

后为每个旧项目在 composer.json 文件中添加这些行
"config": {

  "platform": {

    "php": "7.3"

  }

},