influxdb-client-php icon indicating copy to clipboard operation
influxdb-client-php copied to clipboard

Can't use GuzzleHttp\Client 6.5.8 with influxdata/influxdb-client-php 3.4.0

Open fredmef opened this issue 2 years ago • 3 comments

Hello,

I want to use Guzzle Http Client (guzzlehttp/guzzle: 6.5.8) with Influxdb Client 3.4.0 so I've done the followings:

  1. composer require influxdata/influxdb-client-php guzzlehttp/guzzle
  2. and create a client with:
$client = new InfluxDB2\Client([
    "url" => "http://localhost:8086",
    "token" => "my-token",
    "bucket" => "my-bucket",
    "org" => "my-org",
    "precision" => InfluxDB2\Model\WritePrecision::NS
]);

But when I connect this client I've the following error:

[23-Nov-2023 16:42:06 UTC] PHP Fatal error:  Uncaught TypeError: InfluxDB2\DefaultApi::configuredClient(): Argument #1 ($client) must be of type Psr\Http\Client\ClientInterface, GuzzleHttp\Client given, called in /var/www/html/vendor/influxdata/influxdb-client-php/src/InfluxDB2/DefaultApi.php on line 64 and defined in /var/www/html/vendor/influxdata/influxdb-client-php/src/InfluxDB2/DefaultApi.php:93

Can you explain me what I'm doing wrong ?

Regards.

fredmef avatar Nov 23 '23 16:11 fredmef

Hi @fredmef,

Thank you for using our client.

Our client requires a PSR-18 HTTP client implementation. According to the Guzzle changelog, support for PSR-18 starts from version 7.0.0. Could you please try updating your Guzzle library to a version at or above 7.0.0?

Best regards

bednar avatar Nov 24 '23 07:11 bednar

Hi @bednar, thanks to your answer. Since I'm using Drupal 9.5.11, I'm stucked to guzzlehttp/guzzle: 6.5.8. So I'll wait to upgrade to Drupal 10 and the ability to use Guzzle 7 to use the latest InfluxDB php client. Regards

fredmef avatar Nov 24 '23 08:11 fredmef

The InfluxDB client is able to run with any implementation of PSR-18 compliant HTTP client - https://packagist.org/providers/psr/http-client-implementation. You can use different HTTP client which is compatible with your Drupal.

For more info see https://github.com/influxdata/influxdb-client-php#custom-http-client

bednar avatar Nov 24 '23 09:11 bednar