Async PHP client for InfluxDB

0.5.0 2017-10-16 08:02 UTC

This package is auto-updated.

Last update: 2024-04-12 04:13:28 UTC


An asyncronous client for InfluxDB, implemented via ReactPHP.

Build Status Latest Stable Version License


Use Composer

composer require stefanotorresi/influxdb-php-async


Each client implementation exposes three main methods:

interface AsyncClient
    public function query(string $query, array $params = []): Promise;
    public function write(string $payload, array $params = []): Promise;
    public function ping(): Promise;
    /* etc. */

The default implementation uses Buzz React and we'll use it throughout the rest of this document.

Here is a basic usage example where we first create a database, then write a line to it:

$client = new ReactHttpClient();

    ->query('CREATE DATABASE test')
    ->then(function($response) use ($client) {
        return $client->write('measure,tag="foo" value="bar"', ['db' => 'test']);


Note that you need to run the ReactPHP event loop. If you don't inject your own, a default loop is composed by the client, and can be started via the run method.

This API assumes that you're familiar with ReactPHP promises.


These are the default options:

    'host'           => 'localhost',
    'port'           => 8086,
    'database'       => '',
    'username'       => '',
    'password'       => '',
    'socket_options' => [],

You can change them at instantion time, defaults will be merged with the one passed:

$options = [ 
    'host' => 'influx-db.domain.tld', 
    'socket_options' => [
        'tls' => true,

$client = new ReactHttpClient($options);

For details about the socket_options key, please refer to react/socket documentation.

Future developments / TO-DO list

  • An UDP client implemented with react/datagram.
  • A QueryBuilder, possibly identical to the one in the official influxdb-php client.
  • A set of response decoders that convert the JSON body from PSR-7 Responses to something more readily consumable.
  • Explore the possibility of merging this package into the official sdk.


This package is released under the MIT license.