diff --git a/clients/guzzle5-adapter.rst b/clients/guzzle5-adapter.rst index bbdac9c..4b441c3 100644 --- a/clients/guzzle5-adapter.rst +++ b/clients/guzzle5-adapter.rst @@ -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 :doc:`discovery ` layer:: + + 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/ diff --git a/clients/guzzle6-adapter.rst b/clients/guzzle6-adapter.rst index 55f4b27..3d510e0 100644 --- a/clients/guzzle6-adapter.rst +++ b/clients/guzzle6-adapter.rst @@ -3,6 +3,9 @@ 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: @@ -10,7 +13,10 @@ not yet included in your project), run: $ 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; diff --git a/clients/includes/install-discovery.inc b/clients/includes/install-discovery.inc new file mode 100644 index 0000000..68c431d --- /dev/null +++ b/clients/includes/install-discovery.inc @@ -0,0 +1,6 @@ +Alternatively you can install the :doc:`discovery ` layer +to be able to automatically find installed resources, like factories: + +.. code-block:: bash + + $ composer require php-http/discovery diff --git a/clients/includes/install-message-factory.inc b/clients/includes/install-message-factory.inc new file mode 100644 index 0000000..6ef7db4 --- /dev/null +++ b/clients/includes/install-message-factory.inc @@ -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 + +In order to provide full interoperability, message implementations are +accessed through :doc:`factories `. Message factories for +`Diactoros`_ and `Guzzle PSR-7`_ are available in the +:doc:`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 diff --git a/clients/socket-client.rst b/clients/socket-client.rst index b1a2875..66e5895 100644 --- a/clients/socket-client.rst +++ b/clients/socket-client.rst @@ -21,6 +21,8 @@ To install the Socket client, run: $ composer require php-http/socket-client +.. include:: includes/install-message-factory.inc + Usage -----