Skip to content

Commit df79a8d

Browse files
authored
Show more examples with config (#202)
* Show more examples with config * Promote createWithConfig
1 parent 1f7b041 commit df79a8d

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

clients/guzzle6-adapter.rst

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,32 @@ not yet included in your project), run:
1616
Usage
1717
-----
1818

19-
Begin by creating a Guzzle client, passing any configuration parameters you
20-
like::
19+
To create a Guzzle6 adapter you should use the `createWithConfig()` function. It will let you to pass Guzzle configuration
20+
to the client::
2121

22-
use GuzzleHttp\Client as GuzzleClient;
22+
use Http\Adapter\Guzzle6\Client as GuzzleAdapter;
2323

2424
$config = [
25-
// Config params
25+
'verify' => false,
26+
'timeout' => 2,
27+
'handler' => //...
28+
// ...
2629
];
27-
$guzzle = new GuzzleClient($config);
30+
$adapter = GuzzleAdapter::createWithConfig($config);
2831

29-
Then create the adapter::
32+
.. note::
3033

31-
use Http\Adapter\Guzzle6\Client as GuzzleAdapter;
34+
If you want even more control over your Guzzle object, you may give a Guzzle client as first argument to the adapter's
35+
constructor::
3236

33-
$adapter = new GuzzleAdapter($guzzle);
37+
use GuzzleHttp\Client as GuzzleClient;
38+
use Http\Adapter\Guzzle6\Client as GuzzleAdapter;
39+
40+
$config = ['verify' => false ];
41+
// ...
42+
$guzzle = new GuzzleClient($config);
43+
// ...
44+
$adapter = new GuzzleAdapter($guzzle);
3445

3546
And use it to send synchronous requests::
3647

@@ -50,6 +61,7 @@ Or send asynchronous ones::
5061
// Returns a Http\Promise\Promise
5162
$promise = $adapter->sendAsyncRequest(request);
5263

64+
5365
.. include:: includes/further-reading-async.inc
5466

5567
.. _Guzzle 6 HTTP client: http://docs.guzzlephp.org/

0 commit comments

Comments
 (0)