【问题标题】:How to resolve Laravel Composer Issue - Your requirements could not be resolved to an installable set of packages如何解决 Laravel Composer 问题 - 您的需求无法解析为一组可安装的软件包
【发布时间】:2021-07-24 10:03:57
【问题描述】:

我正在使用 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.

然后当我更新作曲家时,错误是这样的:

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,我会遇到部署项目的问题。

我该如何解决这个问题?

谢谢

【问题讨论】:

    标签: php laravel package


    【解决方案1】:

    打开您的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"
    
      }
    
    },
    

    【讨论】:

    • 我原以为设置 php 版本是有原因的,所以只是更改它可能会导致其他问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-11-20
    • 2020-02-12
    • 1970-01-01
    • 1970-01-01
    • 2015-06-20
    • 2021-10-28
    • 2016-03-22
    相关资源
    最近更新 更多