chromabits / influx-php
Simple client for InfluxDB
0.2.1
2015-01-16 22:48 UTC
Requires
- guzzlehttp/guzzle: ~4.1.8
Requires (Dev)
- phpunit/phpunit: ~4.6@dev
This package is not auto-updated.
Last update: 2024-11-09 16:53:21 UTC
README
Simple PHP client for InfluxDB, an open-source, distributed, time series, events, and metrics database.
This is a fork of crodas/InfluxPHP
Installation
The easiest way is to install it via composer
composer require chromabits/influx-php
Usage
You need to create a client object.
use Chromabits\InfluxClient\Client; $client = new Client( "localhost" /*default*/, 8086 /* default */, "root" /* by default */, "root" /* by default */ );
The first time you should create an database.
$db = $client->createDatabase("foobar"); $db->createUser("foo", "bar"); // <-- create user/password
Create data is very simple.
$db = $client->foobar; $db->insert("some label", ['foobar' => 'bar']); // single input $db->insert("some label", [ ['foobar' => 'bar'], ['foobar' => 'foo'], ]); // multiple input, this is better :-)
Now you can get the database object and start querying.
$db = $client->foobar; // OR $db = $client->getDatabase("foobar"); foreach ($db->query("SELECT * FROM foo;") as $row) { var_dump($row, $row->time); }