tray-labs/laravel-influxdb
最新稳定版本:1.0.12
Composer 安装命令:
composer require tray-labs/laravel-influxdb
包简介
A service made to provide, set up and use the library from influxdata influxphp in Laravel.
README 文档
README
A service made to provide, set up and use the library from influxdata influxdb-php in Laravel.
Installing
- Install by composer command:
composer require tray-labs/laravel-influxdb
- Or add this line to require section of
composer.jsonand execute on your terminal$ composer install
"require": { "tray-labs/laravel-influxdb": "^1.0" }
Register service provider(pick one of two).
Laravel: inconfig/app.phpfile,Laravel 5.5+ supports package discovery automatically, you should skip this step'providers' => [ // ... TrayLabs\InfluxDB\Providers\ServiceProvider::class, ]
'aliases' => [ // ... 'InfluxDB' => TrayLabs\InfluxDB\Facades\InfluxDB::class, ]
Lumen: inbootstrap/app.phpfile// config $app->configure('InfluxDB'); $app->register(TrayLabs\InfluxDB\Providers\LumenServiceProvider::class); $app->alias('InfluxDB', TrayLabs\InfluxDB\Facades\InfluxDB::class);
- Define env variables to connect to InfluxDB
INFLUXDB_HOST=localhost INFLUXDB_PORT=8086 INFLUXDB_USER=some_user INFLUXDB_PASSWORD=some_password INFLUXDB_SSL=false INFLUXDB_VERIFYSSL=false INFLUXDB_TIMEOUT=0 INFLUXDB_DBNAME=some_database INFLUXDB_UDP_ENABLED=false # Activate UDP INFLUXDB_UDP_PORT=4444 # Port for UDP
- Write this into your terminal inside your project
Laravelphp artisan vendor:publish
Lumencp vendor/TrayLabs/lumen-influxdb/config/InfluxDB.php config/InfluxDB.php
Reading Data
<?php // 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();
Writing Data
<?php // 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);
License
This project is licensed under the MIT License
统计信息
- 总下载量: 158.33k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 73
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-06-13