gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 01:41:49 25 4
gpt4 key购买 nike

我有以下 composer.json文件:

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

我想强行的地方 aeris/guzzle-http-mock package使用不同版本的 guzzlehttp/guzzle (例如 5.3.1 ),但似乎要求是从 composer.json 中读取的文件托管在 packagist.org 上。是否有任何解决方法可以覆盖这些要求?

所以而不是:
"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 property它旨在替换给定的包,因此其他包不会下载它。例如:

{
"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 aliases喜欢:
"guzzlehttp/guzzle": "dev-5.3.0 as 5.0.3"

但是在以这种方式进行测试后无论如何它都无法按预期工作,但也许有办法。

相关 GitHub 线程: How to replace the 3rd party dependency?

关于dependencies - 如何覆盖由在 packagist.org 上托管的 composer.json 定义的所需版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46409609/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com