PHPackages                             corley/influxdb-http-handlers - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. corley/influxdb-http-handlers

ActiveLibrary[HTTP &amp; Networking](/categories/http)

corley/influxdb-http-handlers
=============================

111PHP

Since Oct 18Pushed 10y ago1 watchersCompare

[ Source](https://github.com/wdalmut/influxdb-http-handlers)[ Packagist](https://packagist.org/packages/corley/influxdb-http-handlers)[ RSS](/packages/corley-influxdb-http-handlers/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

InfluxDB response handlers
==========================

[](#influxdb-response-handlers)

[![Build Status](https://camo.githubusercontent.com/00d9d9db2c08adc7efa3dffcee3a8bb6312feb7818e2ffdb8f9fbe4650abfe84/68747470733a2f2f7472617669732d63692e6f72672f636f726c65792f696e666c757864622d687474702d68616e646c6572732e737667)](https://travis-ci.org/corley/influxdb-http-handlers)

Thanks to GuzzleHTTP middleware infrastructure we can convert HTTP responses from InfluxDB in a more simple data structure, in the same way we can also manage query errors.

Convert your data structure
---------------------------

[](#convert-your-data-structure)

Actually the InfluxDB-PHP-SDK (by Corley) do not manage the JSON messages received from InfluxDB. That mean that you have to deal with this kind of data:

```
array(1) {
  'results' =>
  array(1) {
    [0] =>
    array(1) {
      'series' =>
      array(1) {
        ...
      }
    }
  }
}
```

If you prefere a more simple data structure, you can append response handlers to your GuzzleHTTP client in order to convert the InfluxDB response directly at runtime and obtain something more simple and readable

```
array(1) {
  'cpu' => array(2) {
    [0] => array(4) {
      'time' => string(30) "2015-09-09T20:42:07.927267636Z"
      'value1' => int(1)
      'value2' => int(2)
      'valueS' => string(6) "string"
    }
    [1] => array(4) {
      'time' => string(30) "2015-09-09T20:42:51.332853369Z"
      'value1' => int(2)
      'value2' => int(4)
      'valueS' => string(11) "another-one"
    }
  }
}
```

That is more simple to use than the InfluxDB default response

### Append the response handler

[](#append-the-response-handler)

During your GuzzleHTTP client setup just push the `message_handler` handler

```
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Handler\CurlHandler;
use GuzzleHttp\Client as HttpClient;
use InfluxDB\Client;
use InfluxDB\Options;
use InfluxDB\Adapter\GuzzleAdapter;

$stack = new HandlerStack();
$stack->setHandler(new CurlHandler());
$stack->push(\InfluxDB\Handler\message_handler()); // Push the response handler

$http = new HttpClient(['handler' => $stack]);

$options = new Options();
$adapter = new GuzzleAdapter($http, $options);

$client = new Client($adapter);
```

Error/Exception management
--------------------------

[](#errorexception-management)

Using the same approach you can convert InfluxDB errored responses in PHP Exception using the `exception_handler`. In that way when a query fail with an error message the handler convert that failure in a valid PHP Exception `UnexceptionValueException`

Just push the `exception_handler` layer in your GuzzleHTTP client

```
$stack->push(\InfluxDB\Handler\exception_handler()); // Push the response handler
```

Layer order
-----------

[](#layer-order)

Handlers that modifies the InfluxDB response should be placed in order:

- `exception_hanlder` as first
- `message_handler`

You can append how many handlers you want

```
$stack->push(\InfluxDB\Handler\exception_handler());
$stack->push(\InfluxDB\Handler\message_handler());
```

In that way you will get new responses format and error messages

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/c4765ec4150d94839948ac55e8d87bdaf2af9a7b96fc2cd023dca366d54ff9ca?d=identicon)[wdalmut](/maintainers/wdalmut)

---

Top Contributors

[![wdalmut](https://avatars.githubusercontent.com/u/551974?v=4)](https://github.com/wdalmut "wdalmut (5 commits)")

### Embed Badge

![Health badge](/badges/corley-influxdb-http-handlers/health.svg)

```
[![Health](https://phpackages.com/badges/corley-influxdb-http-handlers/health.svg)](https://phpackages.com/packages/corley-influxdb-http-handlers)
```

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M319](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M293](/packages/pusher-pusher-php-server)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78026.4M414](/packages/react-http)[php-http/curl-client

PSR-18 and HTTPlug Async client with cURL

48347.0M384](/packages/php-http-curl-client)[smi2/phpclickhouse

PHP ClickHouse Client

84310.1M71](/packages/smi2-phpclickhouse)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
