Skip to content

Show more examples with config #202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 10, 2017
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/