如何覆盖由composer.json定义的所需版本托管在packagist.org上



我有以下composer.json文件:

{
  "require": {
    "guzzlehttp/guzzle": "^5.3"
  },
  "require-dev": {
    "aeris/guzzle-http-mock": ">=1.1.5"
  }
}

我想强制aeris/guzzle-http-mock软件包使用不同版本的guzzlehttp/guzzle(例如5.3.1),但是似乎从 packagist.org上托管的composer.json文件中读取了需求。有没有解决这些要求的解决方法?

所以:

"guzzlehttp/guzzle": "~5.0.0"

我想设置:

"guzzlehttp/guzzle": "^5.3"

理想情况下仅更改我的本地composer.json文件。

当前命令显示冲突错误:

$ composer install --prefer-source -vvv
Reading ./composer.json
Loading config file ./composer.json
...
Reading ~/.composer/cache/repo/https---packagist.org/provider-aeris$guzzle-http-mock.json from cache
Resolving dependencies through SAT
Dependency resolution completed in 0.000 seconds
Reading ~/.composer/cache/repo/https---packagist.org/provider-guzzlehttp$guzzle.json from cache
Your requirements could not be resolved to an installable set of packages.
  Problem 1
    - Installation request for aeris/guzzle-http-mock >=1.1.5 -> satisfiable by aeris/guzzle-http-mock[1.1.5].
    - aeris/guzzle-http-mock 1.1.5 requires guzzlehttp/guzzle ~5.0.0 -> satisfiable by guzzlehttp/guzzle[5.0.0, 5.0.1, 5.0.2, 5.0.3] but these conflict with your requirements or minimum-stability.

通过使用旨在替换给定软件包的 replace属性可以解决解决方案,因此其他软件包不会下载它。例如:

{
  "require": {
    "aeris/guzzle-http-mock": ">=1.1.5"
  },
  "replace": {
    "guzzlehttp/guzzle": "~5.0.0"
  },
  "minimum-stability": "dev",
  "prefer-stable": true
}

将忽略guzzlehttp/guzzle依赖关系,并且不会下载,但是正确的版本需要单独或作为软件包的一部分提供。

例如,可以通过添加以下方式手动克隆所需的存储库:

"repositories": [
  {
    "type": "vcs",
    "url": "https://github.com/guzzle/guzzle.git"
  }
]

另一个想法是使用 inline别名喜欢:

"guzzlehttp/guzzle": "dev-5.3.0 as 5.0.3"

,但是在这种方式测试后,它无论如何都无法正常工作,但是也许有办法。


相关的github线程:如何替换第三方依赖性?

相关内容

  • 没有找到相关文章

最新更新