Skip to content

Commit

Permalink
Merge pull request #8 from pvgennip/laravel-5_4-pr
Browse files Browse the repository at this point in the history
Added Laravel 5.4 compatibility
  • Loading branch information
sergeyklay authored Jun 13, 2017
2 parents 9af5631 + a579018 commit 6a5bb27
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,29 @@
A minimal service provider to set up and use InfluxDB SDK in Laravel 5

### Installation
- Add a line to *require* section of `composer.json` and execute `$ composer install`
- Add a line to the *require* section of `composer.json` and execute `$ composer install`
```js
"require": {
// ...
"pdffiller/laravel-influx-provider": "^1.2"
}
```
- Add a line to `config/app.php`
- Add these lines to `config/app.php`
```php
'providers' => [
// ...
Pdffiller\LaravelInfluxProvider\InfluxDBServiceProvider::class,
]


'aliases' => [
// ...
'Influx' => Pdffiller\LaravelInfluxProvider\InfluxDBFacade::class,
]

```


- Define env variables to connect to InfluxDB
```
LARAVEL_INFLUX_PROVIDER_PROTOCOL=http
Expand All @@ -27,6 +36,11 @@ LARAVEL_INFLUX_PROVIDER_DATABASE=database_name
```

### How to use
```php
$client = new \Influx;
$data = $client::query('SELECT * from "data" ORDER BY time DESC LIMIT 1');
```

```php
$point = [
new \InfluxDB\Point(
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
],
"require": {
"php": ">=5.6",
"illuminate/log": "5.2.*|5.3.*",
"illuminate/support": "5.2.*|5.3.*",
"illuminate/log": "5.2.*|5.3.*|5.4.*",
"illuminate/support": "5.2.*|5.3.*|5.4.*",
"influxdb/influxdb-php": "^1.4",
"monolog/monolog": "^1.19"
},
Expand Down
10 changes: 9 additions & 1 deletion src/InfluxDBServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ class InfluxDBServiceProvider extends ServiceProvider
public function boot()
{
$this->publishes([
__DIR__ . '/config/InfluxDB.php' => config_path('influxdb.php')
$this->configPath() => config_path('influxdb.php')
]);

$this->mergeConfigFrom($this->configPath(), 'influxdb');

if (config('influxdb.use_monolog_handler') === 'true') {
$handler = new InfluxDBMonologHandler($this->getLoggingLevel());
Expand All @@ -32,6 +34,7 @@ public function boot()
public function register()
{
$this->app->singleton('InfluxDB\Client', function($app) {

$protocol = 'influxdb';
if (in_array(config('influxdb.protocol'), ['https', 'udp'])) {
$protocol = config('influxdb.protocol') . '+' . $protocol;
Expand Down Expand Up @@ -67,4 +70,9 @@ private function getLoggingLevel()
'EMERGENCY'
]) ? config('influxdb.logging_level') : Logger::NOTICE;
}

protected function configPath()
{
return __DIR__ . '/config/InfluxDB.php';
}
}

0 comments on commit 6a5bb27

Please sign in to comment.