运行此composer require intervention/image
会抛出此错误:
Using version ^2.3 for intervention/image
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Conclusion: don't install intervention/image 2.3.1
- Conclusion: don't install intervention/image 2.3.2
- Installation request for intervention/image ^2.3 -> satisfiable by intervention/image[2.3.0, 2.3.1, 2.3.2].
- intervention/image 2.3.0 requires guzzlehttp/psr7 ~1.1 -> satisfiable by guzzlehttp/psr7[1.1.0, 1.2.0].
- guzzlehttp/psr7 1.1.0 requires psr/http-message ~1.0 -> satisfiable by psr/http-message[1.0].
- guzzlehttp/psr7 1.2.0 requires psr/http-message ~1.0 -> satisfiable by psr/http-message[1.0].
- Conclusion: don't install psr/http-message 1.0
Installation failed, reverting ./composer.json to its original content.
所以它是由Guzzle引起的(我使用"guzzlehttp/guzzle": "~5.3"
)。但我无法(或者不想)将guzzle更新为6.0,因为它不向后兼容,因此我必须移动大量代码。我可以做一些事情,比如伎俩,还是我必须更新guzzlehttp/guzzle
或intervention/image
?
答案 0 :(得分:3)
使用别名方法有一个严重的缺点:它不会工作!
我怀疑您使用Guzzle 5是您收到邮件的原因,但是为了进行更多调查,我需要您composer.json
的内容,也可能需要composer.lock
文件的内容。< / p>
此处添加的依赖项并不太复杂。 intervention/image
取决于guzzlehttp/psr7 ~1.1
,这取决于psr/http-message ~1.0
。 Guzzle包是一个全新的包,它没有与以前版本的Guzzle 5.x一起使用,PSR包也不应该与任何东西冲突 - 但这正是Composer检测到的。但是,在Composer中解密SAT求解器的错误消息并不容易。求解器可以轻松地为您创建适用于所有要求的解决方案,但精确定位失败非常困难。如果可能的话,Composer会为你做这件事。
有一种工具可以帮助人类调试这种情况:https://packagist.org/packages/clue/graph-composer
它是一个最好与composer global require clue/graph-composer
一起安装的命令行工具,它还需要&#34; graphviz&#34;安装。在现有项目中使用它将揭示当前存在的所有包依赖关系,并可能为您提供可能出错的线索。
答案 1 :(得分:0)
是。您可以尝试使用aliases。 它可能是这样的:
"guzzlehttp/guzzle": "~5.3 as 6.0"
答案 2 :(得分:0)
您可以使用别名来欺骗Composer,认为guzzle的v5.3.0实际上是v6.0。
定义"guzzlehttp/guzzle": "~5.3 as 6.0"
不起作用,因为它只是一个无效的字符串。您必须具体说明版本并插入5.3.0,如下所示:
composer.json
{
"require": {
"intervention/image": "^2.3",
"guzzlehttp/guzzle": "5.3.0 as 6.0"
}
}
您还可以更新代码以使用guzzlehttp/guzzle
v6,但这可能比更改composer.json中的少数字符更多。 ,)
这是一个技巧,但它不会奏效。你可以看一下@Sven的答案。
很明显,你没有测试我发布的内容。别名版本是完成它的一种方法。它不是解决所有依赖问题的圣杯。它是一种解决版本冲突的简单方法。
[50.2MB/9.02s] - Installing react/promise (v2.2.1)
[50.6MB/9.07s] Reading C:/Users/koch/AppData/Local/Composer/files/react/promise/3b6fca09c7d56321057fa8867c8dbe1abf648627.zip from cache
[50.6MB/9.08s] Loading from cache
[50.6MB/9.08s] Extracting archive
[50.7MB/9.47s]
[50.7MB/9.48s] REASON: guzzlehttp/ringphp 1.1.0 requires react/promise ~2.0 -> satisfiable by react/promise[v2.0.0, v2.1.0, v2.2.0, v2.2.1].
[50.7MB/9.48s]
[50.7MB/9.49s] - Installing guzzlehttp/streams (3.0.0)
[50.7MB/9.53s] Reading C:/Users/koch/AppData/Local/Composer/files/guzzlehttp/streams/47aaa48e27dae43d39fc1cea0ccf0d84ac1a2ba5.zip from cache
[50.7MB/9.54s] Loading from cache
[50.7MB/9.54s] Extracting archive
[50.7MB/9.92s]
[50.7MB/9.93s] REASON: guzzlehttp/ringphp 1.1.0 requires guzzlehttp/streams ~3.0 -> satisfiable by guzzlehttp/streams[3.0.0].
[50.7MB/9.93s]
[50.7MB/9.94s] - Installing guzzlehttp/ringphp (1.1.0)
[50.7MB/10.01s] Reading C:/Users/koch/AppData/Local/Composer/files/guzzlehttp/ringphp/dbbb91d7f6c191e5e405e900e3102ac7f261bc0b.zip from cache
[50.7MB/10.02s] Loading from cache
[50.7MB/10.02s] Extracting archive
[50.7MB/10.41s]
[50.7MB/10.41s] REASON: guzzlehttp/guzzle 5.3.0 requires guzzlehttp/ringphp ^1.1 -> satisfiable by guzzlehttp/ringphp[1.1.0].
[50.7MB/10.41s]
[50.7MB/10.43s] - Installing guzzlehttp/guzzle (5.3.0)
[50.7MB/10.49s] Reading C:/Users/koch/AppData/Local/Composer/files/guzzlehttp/guzzle/f3c8c22471cb55475105c14769644a49c3262b93.zip from cache
[50.7MB/10.51s] Loading from cache
[50.7MB/10.51s] Extracting archive
[50.7MB/11.66s]
[50.7MB/11.66s] REASON: Required by root: Install command rule (install guzzlehttp/guzzle 5.3.0)
[50.7MB/11.66s]
[50.7MB/11.69s] - Installing psr/http-message (1.0)
[50.7MB/11.77s] Reading C:/Users/koch/AppData/Local/Composer/files/psr/http-message/85d63699f0dbedb190bbd4b0d2b9dc707ea4c298.zip from cache
[50.7MB/11.78s] Loading from cache
[50.7MB/11.78s] Extracting archive
[50.7MB/11.91s]
[50.7MB/11.91s] REASON: guzzlehttp/psr7 1.2.0 requires psr/http-message ~1.0 -> satisfiable by psr/http-message[1.0].
[50.7MB/11.91s]
[50.7MB/11.94s] - Installing guzzlehttp/psr7 (1.2.0)
[50.7MB/11.98s] Reading C:/Users/koch/AppData/Local/Composer/files/guzzlehttp/psr7/4ef919b0cf3b1989523138b60163bbcb7ba1ff7e.zip from cache
[50.7MB/11.98s] Loading from cache
[50.7MB/11.98s] Extracting archive
[50.7MB/12.61s]
[50.7MB/12.61s] REASON: intervention/image 2.3.2 requires guzzlehttp/psr7 ~1.1 -> satisfiable by guzzlehttp/psr7[1.1.0, 1.2.0].
[50.7MB/12.61s]
[50.7MB/12.64s] - Installing intervention/image (2.3.2)
[50.7MB/12.73s] Reading C:/Users/koch/AppData/Local/Composer/files/intervention/image/1124ff3c6298f0dcf9edf9156623904d7a5c3428.zip from cache
[50.7MB/12.74s] Loading from cache
[50.7MB/12.74s] Extracting archive
[50.7MB/14.72s]
[50.7MB/14.72s] REASON: Required by root: Install command rule (install intervention/image 2.3.0|install intervention/image 2.3.1|install intervention/image 2.3.2)
[50.7MB/14.72s]
[50.3MB/15.09s] intervention/image suggests installing ext-gd (to use GD library based image processing.)
[50.3MB/15.10s] intervention/image suggests installing ext-imagick (to use Imagick based image processing.)
[50.3MB/15.11s] intervention/image suggests installing intervention/imagecache (Caching extension for the Intervention Image library)
[50.4MB/15.17s] Writing lock file