This repository was archived by the owner on Mar 13, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +27
-5
lines changed Expand file tree Collapse file tree 3 files changed +27
-5
lines changed Original file line number Diff line number Diff line change 2
2
A minimal service provider to set up and use InfluxDB SDK in Laravel 5
3
3
4
4
### 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 `
6
6
``` js
7
7
" require" : {
8
8
// ...
9
9
" pdffiller/laravel-influx-provider" : " ^1.2"
10
10
}
11
11
```
12
- - Add a line to ` config/app.php `
12
+ - Add these lines to ` config/app.php `
13
13
``` php
14
14
'providers' => [
15
15
// ...
16
16
Pdffiller\LaravelInfluxProvider\InfluxDBServiceProvider::class,
17
17
]
18
+
19
+
20
+ 'aliases' => [
21
+ // ...
22
+ 'Influx' => Pdffiller\LaravelInfluxProvider\InfluxDBFacade::class,
23
+ ]
24
+
18
25
```
26
+
27
+
19
28
- Define env variables to connect to InfluxDB
20
29
```
21
30
LARAVEL_INFLUX_PROVIDER_PROTOCOL=http
@@ -27,6 +36,11 @@ LARAVEL_INFLUX_PROVIDER_DATABASE=database_name
27
36
```
28
37
29
38
### How to use
39
+ ``` php
40
+ $client = new \Influx;
41
+ $data = $client::query('SELECT * from "data" ORDER BY time DESC LIMIT 1');
42
+ ```
43
+
30
44
``` php
31
45
$point = [
32
46
new \InfluxDB\Point(
Original file line number Diff line number Diff line change 11
11
],
12
12
"require" : {
13
13
"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.* " ,
16
16
"influxdb/influxdb-php" : " ^1.4" ,
17
17
"monolog/monolog" : " ^1.19"
18
18
},
Original file line number Diff line number Diff line change @@ -14,8 +14,10 @@ class InfluxDBServiceProvider extends ServiceProvider
14
14
public function boot ()
15
15
{
16
16
$ this ->publishes ([
17
- __DIR__ . ' /config/InfluxDB.php ' => config_path ('influxdb.php ' )
17
+ $ this -> configPath () => config_path ('influxdb.php ' )
18
18
]);
19
+
20
+ $ this ->mergeConfigFrom ($ this ->configPath (), 'influxdb ' );
19
21
20
22
if (config ('influxdb.use_monolog_handler ' ) === 'true ' ) {
21
23
$ handler = new InfluxDBMonologHandler ($ this ->getLoggingLevel ());
@@ -32,6 +34,7 @@ public function boot()
32
34
public function register ()
33
35
{
34
36
$ this ->app ->singleton ('InfluxDB\Client ' , function ($ app ) {
37
+
35
38
$ protocol = 'influxdb ' ;
36
39
if (in_array (config ('influxdb.protocol ' ), ['https ' , 'udp ' ])) {
37
40
$ protocol = config ('influxdb.protocol ' ) . '+ ' . $ protocol ;
@@ -67,4 +70,9 @@ private function getLoggingLevel()
67
70
'EMERGENCY '
68
71
]) ? config ('influxdb.logging_level ' ) : Logger::NOTICE ;
69
72
}
73
+
74
+ protected function configPath ()
75
+ {
76
+ return __DIR__ . '/config/InfluxDB.php ' ;
77
+ }
70
78
}
You can’t perform that action at this time.
0 commit comments