From a65c0d8fa999ed5f3a64c479d5beddc22116403e Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Sun, 9 Jul 2017 16:15:42 +0200 Subject: [PATCH 1/2] Show more examples with config --- clients/guzzle6-adapter.rst | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/clients/guzzle6-adapter.rst b/clients/guzzle6-adapter.rst index 581f54a..acdc899 100644 --- a/clients/guzzle6-adapter.rst +++ b/clients/guzzle6-adapter.rst @@ -22,7 +22,10 @@ like:: use GuzzleHttp\Client as GuzzleClient; $config = [ - // Config params + 'verify' => false, + 'timeout' => 2, + 'handler' => //... + // ... ]; $guzzle = new GuzzleClient($config); @@ -32,6 +35,15 @@ Then create the adapter:: $adapter = new GuzzleAdapter($guzzle); +.. note:: + + You can also use the quicker `createWithConfig()` function:: + + use Http\Adapter\Guzzle6\Client as GuzzleAdapter; + + $config = ['verify' => false ]; + $adapter = GuzzleAdapter::createWithConfig($config); + And use it to send synchronous requests:: use GuzzleHttp\Psr7\Request; @@ -50,6 +62,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/ From b184462b8131dcfc4ac065d1545c4d153fb0b6bf Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Mon, 10 Jul 2017 09:00:21 +0200 Subject: [PATCH 2/2] Promote createWithConfig --- clients/guzzle6-adapter.rst | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/clients/guzzle6-adapter.rst b/clients/guzzle6-adapter.rst index acdc899..ac18be5 100644 --- a/clients/guzzle6-adapter.rst +++ b/clients/guzzle6-adapter.rst @@ -16,10 +16,10 @@ 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 = [ 'verify' => false, @@ -27,22 +27,21 @@ like:: 'handler' => //... // ... ]; - $guzzle = new GuzzleClient($config); - -Then create the adapter:: - - use Http\Adapter\Guzzle6\Client as GuzzleAdapter; - - $adapter = new GuzzleAdapter($guzzle); + $adapter = GuzzleAdapter::createWithConfig($config); .. note:: - You can also use the quicker `createWithConfig()` function:: + If you want even more control over your Guzzle object, you may give a Guzzle client as first argument to the adapter's + constructor:: + use GuzzleHttp\Client as GuzzleClient; use Http\Adapter\Guzzle6\Client as GuzzleAdapter; $config = ['verify' => false ]; - $adapter = GuzzleAdapter::createWithConfig($config); + // ... + $guzzle = new GuzzleClient($config); + // ... + $adapter = new GuzzleAdapter($guzzle); And use it to send synchronous requests::