前言
最近在用laravel 8.x
测试easywechat: ^6.0-beta8
时踩了不少坑,一本正经的debug了几天后发现一些坑已经在master
分支填完了,所以想着同步升级到最新的6.0-beta10
继续踩坑,但是发现从6.0-beta9
开始@overture
超哥光明正大的把一些依赖改成了更高的版本,但是我的laravel即使升级到最新版的8.78.0,composer update
加-W
也一直提示依赖冲突呀,那就无法安装,无法继续踩坑了。。。
案情重现:composer依赖冲突的提示
运行环境:
PHP 8.0.13
Composer version 2.1.11
Laravel Framework 8.78.0
运行以下命令:
$ composer require "w7corp/easywechat: ^6.0-beta10"
./composer.json has been updated
Running composer update w7corp/easywechat
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires w7corp/easywechat ^6.0-beta10 -> satisfiable by w7corp/easywechat[6.0-beta10].
- w7corp/easywechat 6.0-beta10 requires symfony/http-foundation ^6.0 -> found symfony/http-foundation[v6.0.0-BETA1, ..., 6.1.x-dev] but the package is fixed to v5.4.2 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
Installation failed, reverting ./composer.json and ./composer.lock to their original content.
$ composer require "w7corp/easywechat: ^6.0-beta9"
./composer.json has been updated
Running composer update w7corp/easywechat
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- w7corp/easywechat[6.0-beta9, ..., 6.0-beta10] require symfony/http-foundation ^6.0 -> found symfony/http-foundation[v6.0.0-BETA1, ..., 6.1.x-dev] but the package is fixed to v5.4.2 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
- Root composer.json requires w7corp/easywechat ^6.0-beta9 -> satisfiable by w7corp/easywechat[6.0-beta9, 6.0-beta10].
Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
Installation failed, reverting ./composer.json and ./composer.lock to their original content.
$ composer require "w7corp/easywechat: ^6.0-beta9" -W
./composer.json has been updated
Running composer update w7corp/easywechat --with-all-dependencies
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- laravel/framework is locked to version v8.78.0 and an update of this package was not requested.
- Conclusion: don't install symfony/http-foundation v5.4.0-RC1 (conflict analysis result)
- Conclusion: don't install symfony/http-foundation v6.0.0-RC1 (conflict analysis result)
- Conclusion: don't install symfony/http-foundation v5.4.0 (conflict analysis result)
- Conclusion: don't install symfony/http-foundation v6.0.0 (conflict analysis result)
- Conclusion: don't install one of symfony/http-foundation[v5.4.1], overtrue/socialite[4.0.0] (conflict analysis result)
- Conclusion: install overtrue/socialite 4.0.0 (conflict analysis result)
- Conclusion: don't install symfony/http-foundation v5.4.2 (conflict analysis result)
- Conclusion: don't install symfony/http-foundation v6.0.1 (conflict analysis result)
- Conclusion: don't install symfony/http-foundation v6.0.2 (conflict analysis result)
- facade/ignition is locked to version 2.17.4 and an update of this package was not requested.
- Root composer.json requires w7corp/easywechat ^6.0-beta9 -> satisfiable by w7corp/easywechat[6.0-beta9, 6.0-beta10].
- overtrue/socialite 4.0.0 requires symfony/http-foundation ^6.0 -> satisfiable by symfony/http-foundation[v6.0.0-BETA1, ..., 6.1.x-dev].
- You can only install one version of a package, so only one of these can be installed: symfony/http-foundation[v2.7.0-BETA1, ..., 2.8.x-dev, v3.0.0-BETA1, ..., 3.4.x-dev, v4.0.0-BETA1, ..., 4.4.x-dev, v5.0.0-BETA1, ..., 5.4.x-dev, v6.0.0-BETA1, ..., 6.1.x-dev].
- laravel/framework v8.78.0 requires symfony/http-foundation ^5.4 -> satisfiable by symfony/http-foundation[v5.4.0-BETA1, ..., 5.4.x-dev].
- Conclusion: don't install symfony/http-foundation 5.4.x-dev (conflict analysis result)
Installation failed, reverting ./composer.json and ./composer.lock to their original content.
好吧,不想等laravel9.x。。那就度娘谷哥一下。。找到了这篇 composer引用本地git做为源库发现可以搞定,那就撸一把。。
解决方案记录
一、仓库克隆到本地进行魔改
- git clone到本地,魔改下master分支的composer.json
$ git clone https://github.com/w7corp/easywechat.git
- 在本地git上创建分支commit,打上自己心仪的tag,如
6.0.1-beta10
二、 修改laravel项目的 composer.json
- 新增repositories属性,排除源easywechat包和新增本地的easywechat git目录
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
// 新增repositories属性
"repositories": [
// composer源排除指定的包 [可选],不排除貌似不影响。
{
"type": "composer",
"url": "https://mirrors.aliyun.com/composer",
"exclude": ["w7corp/easywechat"] //从composer源排除掉指定的包
},
// 重点加上以下这个
{
"type": "git",
"url": "/你本地目录/easywechat-git" // 添加本地git地址或远程git地址
}
],
"require": {
// 以下省略一大堆不重要的内容
},
// 以下省略一大堆不重要的内容
}
$ composer require "w7corp/easywechat: ^6.0.1-beta10"% composer require "w7corp/easywechat: ^6.0.1-beta10"
./composer.json has been updated
Running composer update w7corp/easywechat
Loading composer repositories with package information
Updating dependencies
Lock file operations: 12 installs, 0 updates, 0 removals
- Locking nyholm/psr7 (1.4.1)
- Locking nyholm/psr7-server (1.0.2)
- Locking overtrue/socialite (3.5.0)
- Locking php-http/message-factory (v1.0.2)
- Locking psr/cache (2.0.0)
- Locking symfony/cache (v5.4.2)
- Locking symfony/cache-contracts (v2.5.0)
- Locking symfony/http-client (v5.4.2)
- Locking symfony/http-client-contracts (v2.5.0)
- Locking symfony/psr-http-message-bridge (v2.1.2)
- Locking symfony/var-exporter (v6.0.0)
- Locking w7corp/easywechat (6.0.1-beta10)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 12 installs, 0 updates, 0 removals
- Downloading symfony/http-client (v5.4.2)
- Downloading symfony/cache (v5.4.2)
- Syncing w7corp/easywechat (6.0.1-beta10) into cache
0/2 [>---------------------------] 0% Failed downloading symfony/http-client, trying the next URL (404: The "https://mirrors.aliyun.com/composer/dists/symfony/http-client/5e344f1402584a56631c81a24ec9403e3159c790.zip" file could not be downloaded (HTTP/2 404 ))
1/2 [==============>-------------] 50% Failed downloading symfony/cache, trying the next URL (404: The "https://mirrors.aliyun.com/composer/dists/symfony/cache/8aad4b69a10c5c51ab54672e78995860f5e447ec.zip" file could not be downloaded (HTTP/2 404 ))
- Installing php-http/message-factory (v1.0.2): Extracting archive
- Installing psr/cache (2.0.0): Extracting archive
- Installing symfony/cache-contracts (v2.5.0): Extracting archive
- Installing symfony/http-client-contracts (v2.5.0): Extracting archive
- Installing symfony/var-exporter (v6.0.0): Extracting archive
- Installing symfony/psr-http-message-bridge (v2.1.2): Extracting archive
- Installing symfony/http-client (v5.4.2): Extracting archive
- Installing symfony/cache (v5.4.2): Extracting archive
- Installing overtrue/socialite (3.5.0): Extracting archive
- Installing nyholm/psr7-server (1.0.2): Extracting archive
- Installing nyholm/psr7 (1.4.1): Extracting archive
- Installing w7corp/easywechat (6.0.1-beta10): Cloning 4064a7a14c from cache
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: facade/ignition
Discovered Package: fruitcake/laravel-cors
Discovered Package: laravel/sail
Discovered Package: laravel/sanctum
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Package manifest generated successfully.
86 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> @php artisan vendor:publish --tag=laravel-assets --ansi --force
No publishable resources for tag [laravel-assets].
Publishing complete.
- 喔呵~搞定,继续踩坑
引用: