我正在尝试使用 GuzzleHttp,但我'Class 'GuzzleHttp\Client' not found'
一直都有。我谷歌了一下,每个人都说要composer require guzzlehttp/guzzle
在项目文件夹中制作。但是当我在控制台中输入它时,我有
Using version ^6.3 for guzzlehttp/guzzle
./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
- don't install bower-asset/yii2-pjax 2.0.7.1|remove yiisoft/yii2-app-basic No version set (parsed as 1.0.0)
- remove yiisoft/yii2-app-basic No version set (parsed as 1.0.0)|remove bower-asset/yii2-pjax 2.0.7.1
- don't install bower-asset/yii2-pjax 2.0.7.1|remove yiisoft/yii2-app-basic No version set (parsed as 1.0.0)
- Installation request for yiisoft/yii2-app-basic No version set (parsed as 1.0.0) -> satisfiable by yiisoft/yii2-app-basic[No version set (parsed as 1.0.0)].
- Installation request for bower-asset/yii2-pjax (locked at 2.0.7.1) -> satisfiable by bower-asset/yii2-pjax[2.0.7.1].
Installation failed, reverting ./composer.json to its original content.
我试图删除它,但 我的项目中的remove yiisoft/yii2-app-basic
输出是composer.json
yiisoft/yii2-app-basic is not required in your composer.json and has not been removed Package "yiisoft/yii2-app-basic" listed for update is not installed. Ignoring. Loading composer repositories with package information Updating dependencies (including require-dev) Nothing to install or update Generating autoload files
"require": {
"php": ">=5.4.0",
"yiisoft/yii2": "~2.0.14",
"yiisoft/yii2-bootstrap": "~2.0.0",
"yiisoft/yii2-swiftmailer": "~2.0.0 || ~2.1.0",
"guzzlehttp/guzzle": "~6.3"
},
如果有帮助的话,我已经通过全局安装了作曲家sudo apt-get install composer
答案1
好吧,我决定按照关联,但我的安装已损坏而不是已验证,所以我开始朝这个方向挖掘。我遇到了一些 snapd 问题,我在 stackoverflow 上找到了解决方案,但找不到链接。然后我安装了 composer,但问题没有解决,我以为我又安装错了。但在重新安装之前,我输入了composer update
我的项目文件夹,它开始删除 bower-assets 等,我很高兴,之后composer require guzzlehttp/guzzle
工作正常。但新的错误出现了,The file or directory to be published does not exist: /home/xxx/yyy/zzz/vendor/bower-asset/jquery/dist
我尝试了所有建议的方法解决方案。但什么都没用,所以我决定创建新项目。然后需要 guzzle,现在一切正常。我猜最初的问题出在 composer 和 snapd 上。我希望这篇文章能对某些人有所帮助。