GuzzleHttp 在 Laravel 上突然给我一个错误

1 php laravel composer-php guzzlehttp

我的项目突然出现这个错误:

Argument 1 passed to Vonage\Client::setHttpClient() must be an instance of Psr\Http\Client\ClientInterface, instance of GuzzleHttp\Client given, called in /home/vagrant/Code/xxx/vendor/nexmo/client-core/src/Client.php
Run Code Online (Sandbox Code Playgroud)

这是包中的一小部分代码:

        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('\GuzzleHttp\Client')) {
            $client = new \GuzzleHttp\Client();
        } elseif (class_exists('\Http\Adapter\Guzzle6\Client')) {
            /** @noinspection CallableParameterUseCaseInTypeContextInspection */
            /** @noinspection PhpUndefinedNamespaceInspection */
            /** @noinspection PhpUndefinedClassInspection */
            $client = new \Http\Adapter\Guzzle6\Client();
        }
    }

    $this->setHttpClient($client);
Run Code Online (Sandbox Code Playgroud)

我尝试使用以下命令更新 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].
Run Code Online (Sandbox Code Playgroud)

我不知道我能做什么:(

请帮我解决这个问题,谢谢!

小智 5

我在 Laravel 7 上遇到了同样的错误,使用 Vonage。就这样度过了一个晚上。对我来说,在 .env 中设置:

NEXMO_HTTP_CLIENT="Http\\Adapter\\Guzzle6\\Client"
Run Code Online (Sandbox Code Playgroud)

如果您没有更改 config/nexmo.php,则直接使用它。

不确定这是否是最好的解决方案,但我正在寻找那个 ClientInterface 并找到了这个 Guzzle6/Client