PHP code example of thomasvargiu / influxdb-php-async

1. Go to this page and download the library: Download thomasvargiu/influxdb-php-async library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

thomasvargiu / influxdb-php-async example snippets


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

$client = new ReactHttpClient();

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

$client->run();

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

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

$client = new ReactHttpClient($options);