Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Add support for Lumen (#16)
Browse files Browse the repository at this point in the history
Resolves #14
  • Loading branch information
mheap authored Oct 16, 2017
1 parent f4cd2a4 commit eaa6189
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,41 @@ Or add an alias in your `config/app.php`:
],
```

### Using Nexmo-Laravel with Lumen

Nexmo-Laravel works with Lumen too! You'll need to do a little work by hand
to get it up and running. First, install the package using composer:


```bash
composer require nexmo/laravel
```

Next, we have to tell Lumen that our library exists. Update `bootstrap/app.php`
and register the `NexmoServiceProvider`:

```php
$app->register(Nexmo\Laravel\NexmoServiceProvider::class);
```

Finally, we need to configure the library. Unfortunately Lumen doesn't support
auto-publishing files so you'll have to create the config file yourself by creating
a config directory and copying the config file out of the package in to your project:

```bash
mkdir config
cp vendor/nexmo/laravel/config/nexmo.php config/nexmo.php
```

At this point, set `NEXMO_KEY` and `NEXMO_SECRET` in your `.env` file and it should
be working for you. You can test this with the following route:

```php
$router->get('/', function () use ($router) {
app(Nexmo\Client::class);
});
```

Configuration
-------------

Expand Down
12 changes: 8 additions & 4 deletions src/NexmoServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@ public function boot()
// Config file path.
$dist = __DIR__.'/../config/nexmo.php';

// Publishes config File.
$this->publishes([
$dist => config_path('nexmo.php'),
]);
// If we're installing in to a Lumen project, config_path
// won't exist so we can't auto-publish the config
if (function_exists('config_path')) {
// Publishes config File.
$this->publishes([
$dist => config_path('nexmo.php'),
]);
}

// Merge config.
$this->mergeConfigFrom($dist, 'nexmo');
Expand Down

0 comments on commit eaa6189

Please sign in to comment.