Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions clients/guzzle6-adapter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,32 @@ not yet included in your project), run:
Usage
-----

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

use GuzzleHttp\Client as GuzzleClient;
use Http\Adapter\Guzzle6\Client as GuzzleAdapter;

$config = [
// Config params
'verify' => false,
'timeout' => 2,
'handler' => //...
// ...
];
$guzzle = new GuzzleClient($config);
$adapter = GuzzleAdapter::createWithConfig($config);

Then create the adapter::
.. note::

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

$adapter = new GuzzleAdapter($guzzle);
use GuzzleHttp\Client as GuzzleClient;
use Http\Adapter\Guzzle6\Client as GuzzleAdapter;

$config = ['verify' => false ];
// ...
$guzzle = new GuzzleClient($config);
// ...
$adapter = new GuzzleAdapter($guzzle);

And use it to send synchronous requests::

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


.. include:: includes/further-reading-async.inc

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