PHP code example of iankibet / influxdb

1. Go to this page and download the library: Download iankibet/influxdb 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/ */

    

iankibet / influxdb example snippets


use Iankibet\InfluxDb\InfluxDbPoint;
use Iankibet\InfluxDb\Facades\InfluxDb;

// in your controller/method
$point = new InfluxDbPoint();
$point->setMeasurement('measurement_name');
$point->setTags(['tag_key' => 'tag_value']);
$point->setFields(['field_key' => 'field_value']);
$point->setTime(time());

InfluxDb::write($point);

use Iankibet\InfluxDb\Facades\InfluxDb;
$measurement = 'measurement_name';
$fields = [
    'key1'=>'value1',
    'key2'=>'value2'
];
$from = '2021-01-01T00:00:00Z';
$to = '2021-01-02T00:00:00Z';
$res = InfluxDb::query('measurement_name', $fields, $from, $to);
bash
php artisan vendor:publish --provider="Iankibet\InfluxDB\InfluxDBServiceProvide"