Skip to content

Guzzle 5 #84

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 4 commits into from
Feb 1, 2016
Merged
Show file tree
Hide file tree
Changes from 3 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
50 changes: 50 additions & 0 deletions clients/guzzle5-adapter.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1,52 @@
Guzzle5 Adapter
===============

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

Installation
------------

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/guzzle5-adapter

.. include:: includes/install-message-factory.inc

.. include:: includes/install-discovery.inc

Usage
-----

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\Guzzle5\Client as GuzzleAdapter;
use Http\Message\MessageFactory\GuzzleMessageFactory;

$adapter = new GuzzleAdapter($guzzle, new GuzzleMessageFactory());

Or if you installed the :ref:`discovery <discovery>` layer::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you define a label discovery somewhere? if you want to link to the document discovery.rst, its :doc:. :ref: is for linking to labels within some page (anchor links in the same or another page).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I thought I can just link to a page with the same name 😄


use Http\Adapter\Guzzle5\Client as GuzzleAdapter;

$adapter = new GuzzleAdapter($guzzle);

.. warning::

The message factory parameter is mandatory if the discovery layer is not installed.

.. include:: includes/further-reading-sync.inc

.. _Guzzle 5 HTTP client: http://docs.guzzlephp.org/en/5.3/
8 changes: 7 additions & 1 deletion clients/guzzle6-adapter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@ Guzzle 6 Adapter

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

Installation
------------

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
Usage
-----

Begin by creating a Guzzle client, passing any configuration parameters you
like::

use GuzzleHttp\Client as GuzzleClient;
Expand Down
6 changes: 6 additions & 0 deletions clients/includes/install-discovery.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Alternatively you can install the :ref:`discovery <discovery>` layer
to be able to automatically find installed resources, like factories:

.. code-block:: bash

$ composer require php-http/discovery
18 changes: 18 additions & 0 deletions clients/includes/install-message-factory.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
This client does not come with a PSR-7 implementation out of the box, so you have
to install one as well (for example `Guzzle PSR-7`_):

.. code-block:: bash

$ composer require guzzlehttp/psr7
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's failing here as it miss the indent ? (not sure)

Copy link
Contributor

@dbu dbu Feb 1, 2016 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


In order to provide full interoperability, message implementations are
accessed through :ref:`factories <message-factory>`. Message factories for
`Diactoros`_ are `Guzzle PSR-7`_ implementations are available in the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Diactoros and Guzzle

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean remove PSR-7?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace "are" by "and" :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good catch.

:ref:`message <message>` component:

.. code-block:: bash

$ composer require php-http/message

.. _Diactoros: http://docs.guzzlephp.org/en/5.3/
.. _Guzzle PSR-7: https://github.com/guzzle/psr7
2 changes: 2 additions & 0 deletions clients/socket-client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ To install the Socket client, run:

$ composer require php-http/socket-client

.. include:: includes/install-message-factory.inc

Usage
-----

Expand Down