A service made to provide, set up and use the library from influxdata influxdb-client-php in Laravel.
- Install by composer command:
composer require amantinetti/laravel-influxdb2
- Or add this line to require section of
composer.json
and execute on your terminal$ composer install
"require": {
"amantinetti/laravel-influxdb2": "^0.0.1"
}
- Add this lines to yours config/app.php (Use only with Laravel version less than 5.5 )
'providers' => [
// ...
Amantinetti\InfluxDB\Providers\ServiceProvider::class,
]
'aliases' => [
// ...
'InfluxDB' => Amantinetti\InfluxDB\Facades\InfluxDB::class,
]
- Define env variables to connect to InfluxDB
INFLUXDB_URL=http://localhost:8086
INFLUXDB_TOKEN=my-token
INFLUXDB_BUCKET=my-bucket
INFLUXDB_ORG=my-org
- Write this into your terminal inside your project
php artisan vendor:publish
<?php
// executing a query will yield a resultset object
$query_api = InfluxDB::createQueryApi();
$result = $query_api->query('from(bucket:"my-bucket") |> range(start: 1970-01-01T00:00:00.000000001Z) |> last()');
<?php
$write_api = InfluxDB::createWriteApi();
$write_api->write('h2o,location=west value=33i 15');
This project is licensed under the MIT License