InfluxDB implementation for Laravel.
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.
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.
Execute composer inside your project's directory to require the latest version:
composer require padrio/laravel-influxdb
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.
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, ];
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
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
// 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.
Theese are features which will be introduced soon, stay tuned.