diff --git a/clients.rst b/clients.rst index 239e843..5a9b08e 100644 --- a/clients.rst +++ b/clients.rst @@ -20,6 +20,7 @@ Client adapters: .. toctree:: + clients/buzz-adapter clients/guzzle5-adapter clients/guzzle6-adapter clients/react-adapter diff --git a/clients/buzz-adapter.rst b/clients/buzz-adapter.rst new file mode 100644 index 0000000..9a86878 --- /dev/null +++ b/clients/buzz-adapter.rst @@ -0,0 +1,59 @@ +Buzz Adapter +============ + +An HTTPlug adapter for the `Buzz HTTP client`_. + +Installation +------------ + +To install the Buzz adapter, which will also install Buzz itself (if it was +not yet included in your project), run: + +.. code-block:: bash + + $ composer require php-http/buzz-adapter + +.. include:: includes/install-message-factory.inc + +.. include:: includes/install-discovery.inc + +Usage +----- + +Begin by creating a Buzz client, you may pass any listener or configuration parameters to it +like:: + + use Buzz\Browser; + use Buzz\Client\Curl; + use Buzz\Listener\CookieListener; + + $browser = new Browser(); + + $client = new Curl(); + $client->setMaxRedirects(0); + $browser->setClient($client); + + // Create CookieListener + $listener = new CookieListener(); + $browser->addListener($listener); + +Then create the adapter:: + + use Http\Adapter\Buzz\Client as BuzzAdapter; + use Http\Message\MessageFactory\GuzzleMessageFactory; + + $adapter = new BuzzAdapter($browser, new GuzzleMessageFactory()); + +Or if you installed the :doc:`discovery ` layer:: + + use Http\Adapter\Buzz\Client as BuzzAdapter; + + $adapter = new BuzzAdapter($browser); + +.. warning:: + + The message factory parameter is mandatory if the discovery layer is not installed. + +.. include:: includes/further-reading-sync.inc + +.. _Buzz HTTP client: https://github.com/kriswallsmith/Buzz