From 16744f560476633a53e22fd9c37e60e950509408 Mon Sep 17 00:00:00 2001 From: andriyandriyan Date: Wed, 27 May 2020 07:09:24 +0700 Subject: [PATCH 1/2] Add support for Lumen --- src/FcmServiceProvider.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/FcmServiceProvider.php b/src/FcmServiceProvider.php index 6525bd2..15dcc15 100644 --- a/src/FcmServiceProvider.php +++ b/src/FcmServiceProvider.php @@ -2,8 +2,10 @@ namespace Kawankoding\Fcm; +use Illuminate\Foundation\Application as LaravelApplication; use Illuminate\Support\ServiceProvider; use Kawankoding\Fcm\Fcm; +use Laravel\Lumen\Application as LumenApplication; /** * Class FcmServiceProvider @@ -13,9 +15,13 @@ class FcmServiceProvider extends ServiceProvider { public function boot() { - $this->publishes([ - __DIR__ . '/../resources/config/laravel-fcm.php' => config_path('laravel-fcm.php'), - ]); + if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) { + $this->publishes([ + __DIR__ . '/../resources/config/laravel-fcm.php' => config_path('laravel-fcm.php'), + ]); + } elseif ($this->app instanceof LumenApplication) { + $this->app->configure('laravel-fcm'); + } } public function register() From dbddbcb69faa6fecf378ce09043bf00286ab39e4 Mon Sep 17 00:00:00 2001 From: andriyandriyan Date: Wed, 27 May 2020 07:10:23 +0700 Subject: [PATCH 2/2] Add installation instruction for Lumen --- readme.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index ff959a6..6fa8255 100644 --- a/readme.md +++ b/readme.md @@ -10,7 +10,9 @@ You can pull the package via composer : $ composer require kawankoding/laravel-fcm "^0.2.0" ``` -Next, You must register the service provider : +#### Laravel + +You must register the service provider : ```php // config/app.php @@ -53,6 +55,24 @@ return [ ]; ``` +#### Lumen + +Add the following service provider to the `bootstrap/app.php` file +```php +$app->register(Kawankoding\Fcm\FcmServiceProvider::class); +``` + +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` + + +Add the configuration to the `bootstrap/app.php` file + *Important:* this needs to be before the registration of the service provider +```php +$app->configure('laravel-fcm'); +... +$app->register(Kawankoding\Fcm\FcmServiceProvider::class); +``` + Set your FCM Server Key in `.env` file : ```