Skip to content

Commit

Permalink
Merge pull request #44 from andriyandriyan/lumen-support
Browse files Browse the repository at this point in the history
Add Support for Lumen
  • Loading branch information
sayaamirul authored May 27, 2020
2 parents c4f703b + dbddbcb commit 1d3e4f3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
22 changes: 21 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 :

```
Expand Down
12 changes: 9 additions & 3 deletions src/FcmServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down

0 comments on commit 1d3e4f3

Please sign in to comment.