padrio/laravel-influxdb

This package is abandoned and no longer maintained. No replacement package was suggested.

InfluxDB implementation for Laravel.

0.1.3 2019-04-19 19:04 UTC

This package is auto-updated.

Last update: 2021-05-18 00:27:55 UTC


README

GitHub code size in bytes Packagist

laravel-influxdb - Brings InfluxDB to your Laravel Application

Licence: MIT
Author: Pascal Krason p.krason@padr.io
Language: PHP 7.1 Laravel: Min. 5.5 - 5.8
Supports Auto-Discovery: Yes

Introduction

Please note, this package is by far not completed but can be seen as production ready. There are a few features I will implement in the near future such as implementing a queue to boost the write performance or supporting multiple connections. If you have suggestions just open an Issue).

This package just provides a very basic implementation by making everything as easy as writing a configuration - literaly.

Requirements

On the PHP side there are not much requirements, you only need at least PHP 5.6 or 7.1 and the curl-Extension installed. Then you can go ahead and install everything through Composer which will take care of everything else.

Installation

Step 1 - Require as dependency

Execute composer inside your project's directory to require the latest version:

composer require padrio/laravel-influxdb

Step 2 - Enable the package (Optional)

With the release of Laravel 5.5 the "Auto Discovery" feature has been introduced. This automatically registers the ServiceProvider and Facade for you. If somehow this does not work or you simply disabled this feature, just follow the next steps.

Inside config/app.php you need to register the ServiceProvider:

// config/app.php

'providers' => [
    // (...)
    Padrio\InfluxDB\Providers\ServiceProvider::class,  
];

And in the same file there is a section to register an alias for the facades:

// config/app.php

'aliases' => [
    //
    'InfluxDb' => Padrio\InfluxDB\Facade::class,
];

Step 3 - Configuration

First you need to publish our predefined config file using artisan:

php artisan vendor:publish --provider="Padrio\InfluxDB\Providers\ServiceProvider"

which should create the file config/influxdb.php which can be modified to your needs.

You can also either just set the following environment variables, or for development purposes you can just insert them into your .env file:

INFLUXDB_PROTOCOL=http
INFLUXDB_USER=null
INFLUXDB_PASS=null
INFLUXDB_HOST=localhost
INFLUXDB_PORT=8086
INFLUXDB_DATABASE=default
INFLUXDB_QUEUE_ENABLE=false
INFLUXDB_QUEUE_DRIVER=default
INFLUXDB_TIMEOUT=5
INFLUXDB_VERIFY_SSL=true

Examples

Basic example

Since this is just a simple wrapper for the official php library, there is not much to documentate on my side. You can either call the helper function InfluxDB() which returns a instance of InfluxDB\Database.

// Get the Client using a facade
$client = InfluxDB::getClient()

// ... using the helper
$client = InfluxDB();

// Check if the database is existing
var_dump(InfluxDB()->exists()); // returns a bool

// Create the configured database
var_dump(InfluxDB()->craete()); // returns null)

For further instructions, check out the offical documentation.

Multiple connectinos & Queue

Theese are features which will be introduced soon, stay tuned.