Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 6a5bb27

Browse files
authored
Merge pull request #8 from pvgennip/laravel-5_4-pr
Added Laravel 5.4 compatibility
2 parents 9af5631 + a579018 commit 6a5bb27

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,29 @@
22
A minimal service provider to set up and use InfluxDB SDK in Laravel 5
33

44
### Installation
5-
- Add a line to *require* section of `composer.json` and execute `$ composer install`
5+
- Add a line to the *require* section of `composer.json` and execute `$ composer install`
66
```js
77
"require": {
88
// ...
99
"pdffiller/laravel-influx-provider": "^1.2"
1010
}
1111
```
12-
- Add a line to `config/app.php`
12+
- Add these lines to `config/app.php`
1313
```php
1414
'providers' => [
1515
// ...
1616
Pdffiller\LaravelInfluxProvider\InfluxDBServiceProvider::class,
1717
]
18+
19+
20+
'aliases' => [
21+
// ...
22+
'Influx' => Pdffiller\LaravelInfluxProvider\InfluxDBFacade::class,
23+
]
24+
1825
```
26+
27+
1928
- Define env variables to connect to InfluxDB
2029
```
2130
LARAVEL_INFLUX_PROVIDER_PROTOCOL=http
@@ -27,6 +36,11 @@ LARAVEL_INFLUX_PROVIDER_DATABASE=database_name
2736
```
2837

2938
### How to use
39+
```php
40+
$client = new \Influx;
41+
$data = $client::query('SELECT * from "data" ORDER BY time DESC LIMIT 1');
42+
```
43+
3044
```php
3145
$point = [
3246
new \InfluxDB\Point(

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
],
1212
"require": {
1313
"php": ">=5.6",
14-
"illuminate/log": "5.2.*|5.3.*",
15-
"illuminate/support": "5.2.*|5.3.*",
14+
"illuminate/log": "5.2.*|5.3.*|5.4.*",
15+
"illuminate/support": "5.2.*|5.3.*|5.4.*",
1616
"influxdb/influxdb-php": "^1.4",
1717
"monolog/monolog": "^1.19"
1818
},

src/InfluxDBServiceProvider.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ class InfluxDBServiceProvider extends ServiceProvider
1414
public function boot()
1515
{
1616
$this->publishes([
17-
__DIR__ . '/config/InfluxDB.php' => config_path('influxdb.php')
17+
$this->configPath() => config_path('influxdb.php')
1818
]);
19+
20+
$this->mergeConfigFrom($this->configPath(), 'influxdb');
1921

2022
if (config('influxdb.use_monolog_handler') === 'true') {
2123
$handler = new InfluxDBMonologHandler($this->getLoggingLevel());
@@ -32,6 +34,7 @@ public function boot()
3234
public function register()
3335
{
3436
$this->app->singleton('InfluxDB\Client', function($app) {
37+
3538
$protocol = 'influxdb';
3639
if (in_array(config('influxdb.protocol'), ['https', 'udp'])) {
3740
$protocol = config('influxdb.protocol') . '+' . $protocol;
@@ -67,4 +70,9 @@ private function getLoggingLevel()
6770
'EMERGENCY'
6871
]) ? config('influxdb.logging_level') : Logger::NOTICE;
6972
}
73+
74+
protected function configPath()
75+
{
76+
return __DIR__ . '/config/InfluxDB.php';
77+
}
7078
}

0 commit comments

Comments
 (0)