Skip to content

Commit

Permalink
Merge pull request #67 from php-http/guzzle6-doc
Browse files Browse the repository at this point in the history
Add Guzzle 6 adapter docs
  • Loading branch information
dbu committed Jan 5, 2016
2 parents 72aeedc + 3080bd1 commit fa9580b
Showing 1 changed file with 54 additions and 2 deletions.
56 changes: 54 additions & 2 deletions clients/guzzle6-adapter.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1,54 @@
Guzzle6 Adapter
===============
Guzzle 6 Adapter
================

An HTTPlug adapter for the `Guzzle 6 HTTP client`_.

To install the Guzzle adapter, which will also install Guzzle itself (if it was
not yet included in your project), run:

.. code-block:: bash
$ composer require php-http/guzzle6-adapter
Then begin by creating a Guzzle client, passing any configuration parameters you
like::

use GuzzleHttp\Client as GuzzleClient;

$config = [
// Config params
];
$guzzle = new GuzzleClientClient($config);

Then create the adapter::

use Http\Adapter\Guzzle6\Client as GuzzleAdapter;

$adapter = new GuzzleAdapter($guzzle);

And use it to send synchronous requests::

use GuzzleHttp\Psr7\Request;

$request = new Request('GET', 'http://httpbin.org');

// Returns a Psr\Http\Message\ResponseInterface
$response = $adapter->sendRequest($request);

Or send asynchronous ones::

use GuzzleHttp\Psr7\Request;

$request = new Request('GET', 'http://httpbin.org');

// Returns a Http\Promise\Promise
$promise = $adapter->sendAsyncRequest(request);

Further reading
---------------

* Read more about :doc:`promises </components/promise>`.
* Learn how you can decouple your code from any PSR-7 implementation (such as
Guzzle’s above) by using a :ref:`message factory <message-factory>`.

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

0 comments on commit fa9580b

Please sign in to comment.