From 59b397b496b2468139b7742979100357a3ca8ebb Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Sat, 16 Jul 2016 19:18:39 +0200 Subject: [PATCH 1/2] Documentation for the Buzz adapter. This will fix #99 --- clients.rst | 1 + clients/buzz-adapter.rst | 59 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 clients/buzz-adapter.rst 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..d917209 --- /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 GuzzleAdapter($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 From 3c89cb7490078e117d42f0adbe7053c131ade5c6 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Sat, 16 Jul 2016 23:41:51 +0200 Subject: [PATCH 2/2] Typo --- clients/buzz-adapter.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/buzz-adapter.rst b/clients/buzz-adapter.rst index d917209..9a86878 100644 --- a/clients/buzz-adapter.rst +++ b/clients/buzz-adapter.rst @@ -42,7 +42,7 @@ Then create the adapter:: use Http\Adapter\Buzz\Client as BuzzAdapter; use Http\Message\MessageFactory\GuzzleMessageFactory; - $adapter = new GuzzleAdapter($browser, new GuzzleMessageFactory()); + $adapter = new BuzzAdapter($browser, new GuzzleMessageFactory()); Or if you installed the :doc:`discovery ` layer::