我正在使用 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 install时,出现此错误:
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 时,错误就是这样的:
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 版本并将它们绑定(bind)到使用 PHP 7.3 以避免任何问题。在更新 PHP 后为每个旧项目的 composer.json
文件中添加以下行:
"config": {
"platform": {
"php": "7.3"
}
},
关于php - 如何解决 Laravel Composer 问题 - 您的需求无法解析为一组可安装的软件包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67344437/