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

Commit

Permalink
Merge pull request #35 from dragonmantank/v2.0.0
Browse files Browse the repository at this point in the history
Updating dependencies
  • Loading branch information
dragonmantank authored Sep 11, 2019
2 parents babd691 + fcbb1f3 commit 3d46fdd
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 8 deletions.
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Alternatively, add these two lines to your composer require section:
```json
{
"require": {
"nexmo/laravel": "^1.0"
"nexmo/laravel": "^2.0"
}
}
```
Expand Down Expand Up @@ -98,6 +98,30 @@ $router->get('/', function () use ($router) {
});
```

### Dealing with Guzzle Client issues

By default, this package uses `nexmo/client`, which includes a Guzzle adapter for accessing
the API. Some other libraries supply their own Guzzle adapter, leading to composer not being
able to resolve a list of dependencies. You may get an error when adding `nexmo/laravel` to
your application because of this.

The Nexmo client allows you to override the HTTP adapter that is being used. This takes a
bit more configuration, but this package allows you to use `nexmo/client-core` to supply your
own HTTP adapter.

To do this:

1. `composer require nexmo/client-core` to install the Core SDK
2. Install your own `httplug`-compatible adapter. For example, to use Symfony's HTTP Client:
1. `composer require symfony/http-client php-http/message-factory php-http/httplug nyholm/psr7`
3. `composer require nexmo/laravel` to install this package
4. In your `.env` file, add the following configuration:

NEXMO_HTTP_CLIENT="Symfony\\Component\\HttpClient\\HttplugClient"

You can now pull the `Nexmo\Client` object from the Laravel Service Container, or use the Facade
provided by this package.

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

Expand Down
16 changes: 11 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,25 @@
"email": "michael.heap@nexmo.com",
"role": "Developer",
"homepage": "http://twitter.com/mheap"
},
{
"name": "Chris Tankersley",
"email": "chris.tankersley@nexmo.com",
"role": "Developer",
"homepage": "http://twitter.com/dragonmantank"
}
],
"support": {
"email": "devrel@nexmo.com"
},
"require": {
"php": ">=5.6",
"illuminate/support": "^5.2",
"nexmo/client": "^1.0"
"php": "^5.6|^7.1",
"illuminate/support": "^5.2|^6.0",
"nexmo/client": "^2.0"
},
"require-dev": {
"phpunit/phpunit": "^5.3",
"orchestra/testbench": "~3.0"
"phpunit/phpunit": "^5.3|~6.0|~8.0",
"orchestra/testbench": "~3.0|^4.0"
},
"autoload": {
"psr-4": {
Expand Down
14 changes: 13 additions & 1 deletion config/nexmo.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,17 @@
*/

'app' => ['name' => function_exists('env') ? env('NEXMO_APP_NAME', 'NexmoLaravel') : 'NexmoLaravel',
'version' => function_exists('env') ? env('NEXMO_APP_VERSION', '1.1.2') : '1.1.2']
'version' => function_exists('env') ? env('NEXMO_APP_VERSION', '1.1.2') : '1.1.2'],

/*
|--------------------------------------------------------------------------
| Client Override
|--------------------------------------------------------------------------
|
| In the event you need to use this with nexmo/client-core, this can be set
| to provide a custom HTTP client.
|
*/

'http_client' => function_exists('env') ? env('NEXMO_HTTP_CLIENT', '') : '',
];
7 changes: 6 additions & 1 deletion src/NexmoServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,12 @@ protected function createNexmoClient(Config $config)
);
}

return new Client($credentials, $options);
$httpClient = null;
if ($this->nexmoConfigHas('http_client')) {
$httpClient = $this->app->make($config->get(('nexmo.http_client')));
}

return new Client($credentials, $options, $httpClient);
}

/**
Expand Down

0 comments on commit 3d46fdd

Please sign in to comment.