GuzzleHttp在Laravel上突然给我一个错误
我的项目突然出现这个错误:
Argument 1 passed to VonageClient::setHttpClient() must be an instance of PsrHttpClientClientInterface, instance of GuzzleHttpClient given, called in /home/vagrant/Code/xxx/vendor/nexmo/client-core/src/Client.php
这是包中的一小部分代码:
if (is_null($client)) {
// Since the user did not pass a client, try and make a client
// using the Guzzle 6 adapter or Guzzle 7 (depending on availability)
/** @noinspection ClassConstantCanBeUsedInspection */
if (class_exists('GuzzleHttpClient')) {
$client = new GuzzleHttpClient();
} elseif (class_exists('HttpAdapterGuzzle6Client')) {
/** @noinspection CallableParameterUseCaseInTypeContextInspection */
/** @noinspection PhpUndefinedNamespaceInspection */
/** @noinspection PhpUndefinedClassInspection */
$client = new HttpAdapterGuzzle6Client();
}
}
$this->setHttpClient($client);
我尝试使用以下命令更新 guzzlehttp:
composer require guzzlehttp/guzzle
我有这个错误:
Problem 1
- webup/laravel-sendinblue v2.0.3 requires guzzlehttp/guzzle ^6.3 -> satisfiable by guzzlehttp/guzzle[6.5.x-dev].
- webup/laravel-sendinblue v2.0.3 requires guzzlehttp/guzzle ^6.3 -> satisfiable by guzzlehttp/guzzle[6.5.x-dev].
- webup/laravel-sendinblue v2.0.3 requires guzzlehttp/guzzle ^6.3 -> satisfiable by guzzlehttp/guzzle[6.5.x-dev].
- Can only install one of: guzzlehttp/guzzle[7.2.0, 6.5.x-dev].
- Installation request for guzzlehttp/guzzle ^7.2 -> satisfiable by guzzlehttp/guzzle[7.2.0].
- Installation request for webup/laravel-sendinblue (locked at v2.0.3, required as 2.*) -> satisfiable by webup/laravel-sendinblue[v2.0.3].
我不知道我能做什么:(
请帮我解决这个问题,谢谢!
回答
我在 Laravel 7 上遇到了同样的错误,使用 Vonage。就这样度过了一个晚上。对我来说,在 .env 中设置:
NEXMO_HTTP_CLIENT="HttpAdapterGuzzle6Client"
如果您没有更改 config/nexmo.php,则直接使用它。
不确定这是否是最好的解决方案,但我正在寻找那个 ClientInterface 并找到了这个 Guzzle6/Client