PHP code example of tray-labs / laravel-influxdb

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

    

tray-labs / laravel-influxdb example snippets


    'providers' => [
    //  ...
    TrayLabs\InfluxDB\Providers\ServiceProvider::class,
    ]
    

    'aliases' => [
    //  ...
        'InfluxDB' => TrayLabs\InfluxDB\Facades\InfluxDB::class,
    ]
    

  // config
  $app->configure('InfluxDB');
  
    $app->register(TrayLabs\InfluxDB\Providers\LumenServiceProvider::class);
  $app->alias('InfluxDB', TrayLabs\InfluxDB\Facades\InfluxDB::class);
    



// executing a query will yield a resultset object
$result = InfluxDB::query('select * from test_metric LIMIT 5');

// get the points from the resultset yields an array
$points = $result->getPoints();



// create an array of points
$points = array(
    new InfluxDB\Point(
        'test_metric', // name of the measurement
        null, // the measurement value
        ['host' => 'server01', 'region' => 'us-west'], // optional tags
        ['cpucount' => 10], // optional additional fields
        time() // Time precision has to be set to seconds!
    ),
    new InfluxDB\Point(
        'test_metric', // name of the measurement
        null, // the measurement value
        ['host' => 'server01', 'region' => 'us-west'], // optional tags
        ['cpucount' => 10], // optional additional fields
        time() // Time precision has to be set to seconds!
    )
);

$result = InfluxDB::writePoints($points, \InfluxDB\Database::PRECISION_SECONDS);
ini
    php artisan vendor:publish
    
ini
    cp vendor/TrayLabs/lumen-influxdb/config/InfluxDB.php config/InfluxDB.php