ken*_*orb 3 dependencies requirements composer-php
我有以下composer.json文件:
{
"require": {
"guzzlehttp/guzzle": "^5.3"
},
"require-dev": {
"aeris/guzzle-http-mock": ">=1.1.5"
}
}
Run Code Online (Sandbox Code Playgroud)
我想强制aeris/guzzle-http-mock包使用不同版本的guzzlehttp/guzzle(例如5.3.1),但是似乎要求是从packagist.org 上composer.json托管的文件中读取的。是否有任何解决方法可以覆盖这些要求?
所以而不是:
"guzzlehttp/guzzle": "~5.0.0"
Run Code Online (Sandbox Code Playgroud)
我想设置:
"guzzlehttp/guzzle": "^5.3"
Run Code Online (Sandbox Code Playgroud)
理想情况下,只更改我的本地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.
Run Code Online (Sandbox Code Playgroud)
有一种解决方法是使用旨在替换给定包的replace属性,因此其他包不会下载它。例如:
{
"require": {
"aeris/guzzle-http-mock": ">=1.1.5"
},
"replace": {
"guzzlehttp/guzzle": "~5.0.0"
},
"minimum-stability": "dev",
"prefer-stable": true
}
Run Code Online (Sandbox Code Playgroud)
将忽略guzzlehttp/guzzle依赖项并且不会下载它,但是需要单独或作为包的一部分提供正确的版本。
例如,可以通过添加以下内容手动克隆所需的存储库:
"repositories": [
{
"type": "vcs",
"url": "https://github.com/guzzle/guzzle.git"
}
]
Run Code Online (Sandbox Code Playgroud)
另一个想法是使用内联别名,例如:
"guzzlehttp/guzzle": "dev-5.3.0 as 5.0.3"
Run Code Online (Sandbox Code Playgroud)
但是在以这种方式进行测试后无论如何它都无法按预期工作,但也许有办法。
相关 GitHub 线程:如何替换第 3 方依赖项?
| 归档时间: |
|
| 查看次数: |
3760 次 |
| 最近记录: |