Skip to content

Commit 10c168a

Browse files
committed
Add Guzzle 6 adapter docs
1 parent 324d829 commit 10c168a

File tree

1 file changed

+52
-2
lines changed

1 file changed

+52
-2
lines changed

clients/guzzle6-adapter.rst

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,52 @@
1-
Guzzle6 Adapter
2-
===============
1+
Guzzle 6 Adapter
2+
================
3+
4+
An HTTPlug adapter for the `Guzzle 6 HTTP client`_.
5+
6+
To install the Guzzle adapter, which will also install Guzzle itself (if it was
7+
not yet included in your project), run:
8+
9+
.. code-block:: bash
10+
11+
$ composer require php-http/guzzle6-adapter
12+
13+
Then begin by creating a Guzzle client, passing any configuration parameters you
14+
like::
15+
16+
$config = [
17+
// Config params
18+
];
19+
$guzzle = new GuzzleHttp\Client($config);
20+
21+
Then create the adapter::
22+
23+
use Http\Adapter\Guzzle6\Client;
24+
25+
$adapter = new Client($guzzle);
26+
27+
And use it to send synchronous requests::
28+
29+
use GuzzleHttp\Psr7\Request;
30+
31+
$request = new Request('GET', 'http://httpbin.org');
32+
33+
// Returns a Psr\Http\Message\ResponseInterface
34+
$response = $adapter->sendRequest($request);
35+
36+
Or send asynchronous ones::
37+
38+
use GuzzleHttp\Psr7\Request;
39+
40+
$request = new Request('GET', 'http://httpbin.org');
41+
42+
// Returns a Http\Promise\Promise
43+
$promise = $adapter->sendAsyncRequest(request);
44+
45+
Further reading
46+
---------------
47+
48+
* Read more about :doc:`promises </components/promise>`.
49+
* Learn how you can decouple your code from any PSR-7 implementation (such as
50+
Guzzle’s above) by using a :ref:`message factory <message-factory>`.
51+
52+
.. _Guzzle 6 HTTP client: http://docs.guzzlephp.org/

0 commit comments

Comments
 (0)