允许Composer降级对require的依赖关系?

时间:2016-09-16 17:49:12

标签: composer-php

我有一个通过作曲家安装的包需要guzzlehttp >=6.0。根据该要求,composer选择安装6.2.1。

我现在正在尝试要求明确要求6.1.1的依赖项。

我收到以下错误: Problem 1 - Can only install one of: guzzlehttp/guzzle[6.1.1, 6.2.1]. - Can only install one of: guzzlehttp/guzzle[6.2.1, 6.1.1]. - Can only install one of: guzzlehttp/guzzle[6.1.1, 6.2.1]. - chargely/chargify-sdk-php v0.1.1 requires guzzlehttp/guzzle 6.1.1 -> satisfiable by guzzlehttp/guzzle[6.1.1]. - Installation request for chargely/chargify-sdk-php ^0.1.1 -> satisfiable by chargely/chargify-sdk-php[v0.1.1]. - Installation request for guzzlehttp/guzzle (locked at 6.2.1) -> satisfiable by guzzlehttp/guzzle[6.2.1].

此外,composer why确认只有那个版本的guzzle是因为我的>=6.0要求。

理论上,使用降级版本的guzzle,初始要求应该没问题。我如何让作曲家去做呢?

2 个答案:

答案 0 :(得分:4)

如果您有2个包含并发要求的软件包,则可以使用别名。

composer.json中,只需添加:

"require": {
    "guzzlehttp/guzzle": "6.2 as 6.1"
}

然后使用composer require ...添加新包。

请查看more detailed answer了解更多信息。

答案 1 :(得分:0)

只需“要求”正确版本的依赖项,添加新包,然后删除硬编码的版本约束。

摘要(对于具有供应商/依赖项约束的 vendor/current:“^1.0|^2.0”)

composer require vendor/dependency:^1.0
composer require vendor/new
composer remove vendor/dependency

例如

  1. 对于约束为 vendor/currentvendor/dependency:"^1.0|^2.0"
  2. Composer 将安装最高兼容版本 vendor/dependency:2.x
  3. 然后您尝试安装具有 vendor/new => FAIL 约束的 vendor/dependency:"^1.0"(因为您已经安装了过高的供应商/依赖项(2.0)
  4. 然后手动获取正确的供应商/依赖版本 composer require vendor/dependency:^1.0
  5. 获取新包 composer require vendor/new
  6. 移除 composer.json composer remove vendor/dependency 中的硬编码约束
  7. 完成。