Download the PHP package influxdb/influxdb-php without Composer

On this page you can find all versions of the php package influxdb/influxdb-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package influxdb-php

The v1 client libraries for InfluxDB were typically developed and maintained by community members. They have all now been succeeded by v2 client libraries. They are being archived it in favor of the v2 client library. See https://github.com/influxdata/influxdb-php/issues/171.

If there are still users of this v1 client library, and they or somebody else are willing to keep them updated with security fixes at a minimum please reach out on the Community Forums or InfluxData Slack.

influxdb-php

InfluxDB client library for PHP

Build Status Code Climate Test Coverage

Note: This library is for use with InfluxDB 1.x. For connecting to InfluxDB 2.x instances, please use the influxdb-client-php client.

Overview

A easy to use library for using InfluxDB with PHP. Maintained by @thecodeassassin, @gianarb.

The influxdb-php library was created to have php port of the python influxdb client. This way there will be a common abstraction library between different programming languages.

Installation

Installation can be done with composer:

NOTE for PHP 5.3 and PHP 5.4 users

If you use either PHP 5.3 and PHP 5.4, the 0.1.x release is still supported (bug fixes and new release fixes). The 0.1.x branch will work on PHP 5.3 and PHP 5.4 but doesn't contain all the features that the 1.0.0 release has such as UDP support.

Getting started

Initialize a new client object:

This will create a new client object which you can use to read and write points to InfluxDB.

It's also possible to create a client from a DSN (Data Source Name):

Important: don't forget to urlencode() the password (and username for that matter) when using a DSN, especially if it contains non-alphanumeric characters. Not doing so might cause exceptions to be thrown.

Reading data

To fetch records from InfluxDB you can do a query directly on a database:

It's also possible to use the QueryBuilder object. This is a class that simplifies the process of building queries.

Make sure that you enter single quotes when doing a where query on strings; otherwise InfluxDB will return an empty result.

You can get the last executed query from the client:

Reading data using a timeout

In production if you are querying InfluxDB to generate a response to a web or API request, you may want to set a specific timeout for InfluxDB calls rather than the default of letting them run indefinitely.

Writing data

Writing data is done by providing an array of points to the writePoints method on a database:

It's possible to add multiple fields when writing measurements to InfluxDB. The point class allows one to easily write data in batches to influxDB.

The name of a measurement and the value are mandatory. Additional fields, tags and a timestamp are optional. InfluxDB takes the current time as the default timestamp.

You can also write multiple fields to a measurement without specifying a value:

Writing data using udp

First, set your InfluxDB host to support incoming UDP sockets:

Then, configure the UDP driver in the client:

Or simply use a DSN (Data Source Name) to send metrics using UDP:

Note: It is import to note that precision will be ignored when you use UDP. You should always use nanosecond precision when writing data to InfluxDB using UDP.

Timestamp precision

It's important to provide the correct precision when adding a timestamp to a Point object. This is because if you specify a timestamp in seconds and the default (nanosecond) precision is set; the entered timestamp will be invalid.

Please note that exec('date + %s%N') does NOT work under MacOS; you can use PHP's microtime to get a timestamp with microsecond precision, like such:

Creating databases

When creating a database a default retention policy is added. This retention policy does not have a duration so the data will be flushed with the memory.

This library makes it easy to provide a retention policy when creating a database:

You can also alter retention policies:

and list them:

You can add more retention policies to a database:

Client functions

Some functions are too general for a database. So these are available in the client:

Admin functionality

You can use the client's $client->admin functionality to administer InfluxDB via the API.

List all the users:

Granting and revoking privileges

Granting permissions can be done on both the database level and cluster-wide. To grant a user specific privileges on a database, provide a database object or a database name.

Todo

Changelog

1.15.0

1.14.8

1.14.7

1.14.6

1.14.5

1.14.3

1.14.2

1.4.1

1.4.0

1.3.1

1.3.0

1.2.2

1.2.0

1.1.3

1.1.2

1.1.1

1.1.0

1.0.1

1.0.0

0.1.2

0.1.1


All versions of influxdb-php with dependencies

PHP Build Version
Package Version
Requires php Version ^5.5 || ^7.0 || ^8.0
guzzlehttp/guzzle Version ^6.0|^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package influxdb/influxdb-php contains the following files

Loading the files please wait ....