Skip to content

Commit 6e6799b

Browse files
author
Younès El Biache
committed
guzzle custom client + doc
1 parent 336e7a2 commit 6e6799b

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,11 @@ The resolver configuration is defined under the "resolver" key and it has two op
147147
* config: The options passed to the class. If you use the default curl class, the config are the same than the [curl_setopt PHP function](http://php.net/manual/en/function.curl-setopt.php)
148148

149149
```php
150+
151+
// CURL
150152
$config = [
151153
'resolver' => [
152-
'class' => 'Embed\\RequestResolvers\\Curl' //The default resolver used
154+
'class' => 'Embed\\RequestResolvers\\Curl' // The default resolver used
153155

154156
'config' => [
155157
CURLOPT_MAXREDIRS => 20,
@@ -164,6 +166,18 @@ $config = [
164166
]
165167
]
166168
];
169+
170+
// Guzzle (5.x)
171+
$config = [
172+
'resolver' => [
173+
'class' => 'Embed\\RequestResolvers\\Guzzle', // Guzzle resolver used
174+
175+
'config' => [
176+
// optional: if you need to use your custom Guzzle instance
177+
'client' => $myGuzzleClient,
178+
]
179+
]
180+
];
167181
```
168182

169183
### Image info

src/RequestResolvers/Guzzle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Guzzle implements RequestResolverInterface
2929
*/
3030
public function __construct($url, array $config)
3131
{
32-
$this->client = new Client($config ?: []);
32+
$this->client = isset($config['client']) ? $config['client'] : new Client();
3333
$this->request = $this->client->createRequest('GET', $url);
3434
}
3535

0 commit comments

Comments
 (0)