Skip to content

Commit 1d3e4f3

Browse files
authored
Merge pull request #44 from andriyandriyan/lumen-support
Add Support for Lumen
2 parents c4f703b + dbddbcb commit 1d3e4f3

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

readme.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ You can pull the package via composer :
1010
$ composer require kawankoding/laravel-fcm "^0.2.0"
1111
```
1212

13-
Next, You must register the service provider :
13+
#### Laravel
14+
15+
You must register the service provider :
1416

1517
```php
1618
// config/app.php
@@ -53,6 +55,24 @@ return [
5355
];
5456
```
5557

58+
#### Lumen
59+
60+
Add the following service provider to the `bootstrap/app.php` file
61+
```php
62+
$app->register(Kawankoding\Fcm\FcmServiceProvider::class);
63+
```
64+
65+
Also copy the [laravel-fcm.php](https://github.com/kawankoding/laravel-fcm/blob/master/resources/config/laravel-fcm.php) config file to `config/laravel-fcm.php`
66+
67+
68+
Add the configuration to the `bootstrap/app.php` file
69+
*Important:* this needs to be before the registration of the service provider
70+
```php
71+
$app->configure('laravel-fcm');
72+
...
73+
$app->register(Kawankoding\Fcm\FcmServiceProvider::class);
74+
```
75+
5676
Set your FCM Server Key in `.env` file :
5777

5878
```

src/FcmServiceProvider.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
namespace Kawankoding\Fcm;
44

5+
use Illuminate\Foundation\Application as LaravelApplication;
56
use Illuminate\Support\ServiceProvider;
67
use Kawankoding\Fcm\Fcm;
8+
use Laravel\Lumen\Application as LumenApplication;
79

810
/**
911
* Class FcmServiceProvider
@@ -13,9 +15,13 @@ class FcmServiceProvider extends ServiceProvider
1315
{
1416
public function boot()
1517
{
16-
$this->publishes([
17-
__DIR__ . '/../resources/config/laravel-fcm.php' => config_path('laravel-fcm.php'),
18-
]);
18+
if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) {
19+
$this->publishes([
20+
__DIR__ . '/../resources/config/laravel-fcm.php' => config_path('laravel-fcm.php'),
21+
]);
22+
} elseif ($this->app instanceof LumenApplication) {
23+
$this->app->configure('laravel-fcm');
24+
}
1925
}
2026

2127
public function register()

0 commit comments

Comments
 (0)