Skip to content

Commit

Permalink
Merge pull request #198 from gregurco/doc_redefine_client
Browse files Browse the repository at this point in the history
Doc: how to redefine client class
  • Loading branch information
gregurco committed May 4, 2018
2 parents 5ec462b + 5710be2 commit c84a865
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ services:
----
## Learn more
- [How to redefine class used for clients](src/Resources/doc/redefine-client-class.md)
## License
This bundle is released under the [MIT license](src/Resources/meta/LICENSE)
Expand Down
41 changes: 41 additions & 0 deletions src/Resources/doc/redefine-client-class.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# How to redefine class used for clients

GuzzleBundle is using `GuzzleHttp\Client` class to create clients. In some cases you may need to extend/rewrite it.
First of all you need to create your own class, but don't forget to extend `GuzzleHttp\Client`:

```php

namespace Namespace\Of\Your\Client;

use GuzzleHttp\Client;

class AwesomeClient extends Client
{

}
```

And now we have two possibilities to change the default class:

#### Global

Redefine `eight_points_guzzle.http_client.class` parameter.
For example in `config/services.yaml` for Symfony 4 and in `app/config/parameters.yml` in Symfony 2 and 3:

```yaml
parameters:
eight_points_guzzle.http_client.class: Namespace\Of\Your\Client\AwesomeClient
```
Note that this method will redefine class for **all** clients.
#### For specific client
```yaml
eight_points_guzzle:
clients:
api_payment:
class: 'Namespace\Of\Your\Client\AwesomeClient'
```
This method will redefine client class only for specific GuzzleBundle client.

0 comments on commit c84a865

Please sign in to comment.