Skip to content

Commit

Permalink
Show more examples with config (#202)
Browse files Browse the repository at this point in the history
* Show more examples with config

* Promote createWithConfig
  • Loading branch information
Nyholm committed Jul 10, 2017
1 parent 1f7b041 commit df79a8d
Showing 1 changed file with 20 additions and 8 deletions.
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/

0 comments on commit df79a8d

Please sign in to comment.