如何覆盖 packagist.org 上托管的 composer.json 定义的所需版本?
How to override required version defined by composer.json hosted on packagist.org?
我有以下 composer.json
文件:
{
"require": {
"guzzlehttp/guzzle": "^5.3"
},
"require-dev": {
"aeris/guzzle-http-mock": ">=1.1.5"
}
}
我想强制执行 aeris/guzzle-http-mock
package to use different version of 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?
我有以下 composer.json
文件:
{
"require": {
"guzzlehttp/guzzle": "^5.3"
},
"require-dev": {
"aeris/guzzle-http-mock": ">=1.1.5"
}
}
我想强制执行 aeris/guzzle-http-mock
package to use different version of 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?