PHPackages                             crodas/influx-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. crodas/influx-php

ActiveLibrary[Database &amp; ORM](/categories/database)

crodas/influx-php
=================

Simple client for InfluxDB

v0.9.1(10y ago)62159.6k↑62.9%26[2 PRs](https://github.com/crodas/InfluxPHP/pulls)BSD-4-ClausePHP

Since Sep 28Pushed 10y ago5 watchersCompare

[ Source](https://github.com/crodas/InfluxPHP)[ Packagist](https://packagist.org/packages/crodas/influx-php)[ RSS](/packages/crodas-influx-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (6)Used By (0)

InfluxDB [![Build Status](https://camo.githubusercontent.com/6e38493c3893ae6ec728bc4c9c9a442c75e7bb54d85cc6b09edd0b4d37bd116b/68747470733a2f2f7472617669732d63692e6f72672f63726f6461732f496e666c75785048502e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/crodas/InfluxPHP)
========================================================================================================================================================================================================================================================================================

[](#influxdb-)

Simple PHP client for [InfluxDB](http://influxdb.org/), an open-source, distributed, time series, events, and metrics database with no external dependencies.

InfluxDB &gt; v0.9 support
==========================

[](#influxdb--v09-support)

The 0.2.0 version of this library now supports InfluxDB 0.9. Please note that InfluxDB 0.9 is still pre-release software.

InfluxDB v0.8.X users
=====================

[](#influxdb-v08x-users)

Influxdb &gt;=0.9.0 brings many breaking changes to the API. InfluxDB 0.8.X users may use the legacy client by using the 0.1.\* series instead. For the documentation, please have a look at the 0.1.\* version!

How to install it
-----------------

[](#how-to-install-it)

The easiest way is to install it via [composer](http://getcomposer.org)

Create a composer.json file with the following contents:

With InfluxDB 0.9 and above:

```
{
    "require": {
        "crodas/influx-php": "^0.9"
    }
}
```

With InfluxDB 0.8.\*:

```
{
    "require": {
        "crodas/influx-php": "0.1.*"
    }
}
```

How to use it
-------------

[](#how-to-use-it)

You need to create a client object.

```
$client = new \crodas\InfluxPHP\Client(
   "localhost" /*default*/,
   8086 /* default */,
   "root" /* by default */,
   "root" /* by default */
);
```

The first time you should create an database.

```
$db = $client->createDatabase("foobar");
$client->createUser("foo", "bar"); // createUser('username', "password");
```

Show existing users:

```
$users = $client->getUsers();
```

User privileges are controlled by per-databases users. Any user can have 'read', 'write' or 'all' access, represented by the constants InfluxClient::PRIV\_READ, InfluxClient::PRIV\_WRITE and InfluxClient::PRIV\_ALL.

```
$client->grantPrivilege(InfluxClient::PRIV_ALL, 'database', 'username');

// revoke rights by
$client->revokePrivilege(InfluxClient::PRIV_ALL, 'database', 'username');
```

The cluster administrator can be set with:

```
$client->setAdmin('username');

// delete admin righty by:
$client->deleteAdmin('einuser');
```

Create data is very simple.

```
$db = $client->foobar;

// single input:
$db->insert("some label", [ 'fields' => array('value' => 2)]);

// single input; the 'name' identifier will be overwritten by array content:
$db->insert("some label", ['name'=> 'some label', 'fields' => array('value' => 2)]);

// multiple insert, this is better...
// The 'name' field is optional, if not set, the default parameter (here: 'foobar') will be used

$db->insert("foobar", array(
            array('name' => 'lala',   'fields' => array('type' => 'foobar', 'karma' => 25)),
            array(   'fields' => array('type' => 'foobar', 'karma' => 45)),
            ));
```

It is recommended that you encode most metadata into the series Tags.

```
$db->insert("foobar",[['tags' => ['type' => 'one'], 'fields' => ['value' => 10]]]);
```

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);
}
```

If there are multiple result series, a MultipleResultSeriesObject instance will be returned. So if you are not sure about the results of the query, check the type of the returned object.

An example of getting multiple result sets is:

```
// Here the 'type' value is stored as metadata in the tags entry. So if there are two 'type' tags found, you will get two result series
$result = $db->query("SELECT count(value) FROM test1 where  time >= '2015-01-01T12:00:00Z' and time < '2015-01-02T00:00:00Z' group by time(1h), type");
```

Please have a look at the DBTest.php class, you will find some more examples there.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity47

Moderate usage in the ecosystem

Community19

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 73.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~140 days

Total

3

Last Release

3969d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/36463?v=4)[C](/maintainers/crodas)[@crodas](https://github.com/crodas)

---

Top Contributors

[![crodas](https://avatars.githubusercontent.com/u/36463?v=4)](https://github.com/crodas "crodas (33 commits)")[![geschke](https://avatars.githubusercontent.com/u/272754?v=4)](https://github.com/geschke "geschke (9 commits)")[![supertowers](https://avatars.githubusercontent.com/u/882123?v=4)](https://github.com/supertowers "supertowers (2 commits)")[![hvt](https://avatars.githubusercontent.com/u/337754?v=4)](https://github.com/hvt "hvt (1 commits)")

### Embed Badge

![Health badge](/badges/crodas-influx-php/health.svg)

```
[![Health](https://phpackages.com/badges/crodas-influx-php/health.svg)](https://phpackages.com/packages/crodas-influx-php)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90440.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)[wildside/userstamps

Laravel Userstamps provides an Eloquent trait which automatically maintains `created\_by` and `updated\_by` columns on your model, populated by the currently authenticated user in your application.

7511.7M13](/packages/wildside-userstamps)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
