Skip to content

Documentation for the Buzz adapter #115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clients.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Client adapters:

.. toctree::

clients/buzz-adapter
clients/guzzle5-adapter
clients/guzzle6-adapter
clients/react-adapter
Expand Down
59 changes: 59 additions & 0 deletions clients/buzz-adapter.rst
Original file line number Diff line number Diff line change
@@ -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 </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