Skip to content

Commit 8afcc28

Browse files
committed
adjust documentation to PSR-17 and PSR-18, deprecate a couple of obsolete PHP-HTTP adapters and clients
1 parent 9abf1f2 commit 8afcc28

15 files changed

+91
-125
lines changed

clients/artax-adapter.rst

+2-10
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ not yet included in your project), run:
1313
1414
$ composer require php-http/artax-adapter
1515
16-
.. include:: includes/install-message-factory.inc
17-
18-
.. include:: includes/install-discovery.inc
19-
2016
Usage
2117
-----
2218

@@ -28,16 +24,12 @@ Begin by creating a Artax adapter::
2824

2925
$adapter = new ArtaxAdapter(new DefaultClient(), new GuzzleMessageFactory());
3026

31-
Or if you installed the :doc:`discovery </discovery>` layer::
27+
Or relying on :doc:`discovery </discovery>`::
3228

3329
use Http\Adapter\Artax\Client as ArtaxAdapter;
3430

3531
$adapter = new ArtaxAdapter();
3632

37-
.. warning::
38-
39-
The message factory parameter is mandatory if the discovery layer is not installed.
40-
41-
.. include:: includes/further-reading-sync.inc
33+
.. include:: includes/further-reading-async.inc
4234

4335
.. _Artax HTTP client: https://github.com/amphp/artax

clients/buzz-adapter.rst

+6-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
Buzz Adapter
2-
============
1+
Buzz Adapter (deprecated)
2+
=========================
33

4-
An HTTPlug adapter for the `Buzz HTTP client`_.
4+
This adapter only implements the PHP-HTTP synchronous interface. This interface
5+
has been superseded by PSR-18, which the `Buzz HTTP client`_ implements
6+
directly.
57

68
Installation
79
------------
@@ -13,10 +15,6 @@ not yet included in your project), run:
1315
1416
$ composer require php-http/buzz-adapter
1517
16-
.. include:: includes/install-message-factory.inc
17-
18-
.. include:: includes/install-discovery.inc
19-
2018
Usage
2119
-----
2220

@@ -44,16 +42,12 @@ Then create the adapter::
4442

4543
$adapter = new BuzzAdapter($browser, new GuzzleMessageFactory());
4644

47-
Or if you installed the :doc:`discovery </discovery>` layer::
45+
Or relying on :doc:`discovery </discovery>`::
4846

4947
use Http\Adapter\Buzz\Client as BuzzAdapter;
5048

5149
$adapter = new BuzzAdapter($browser);
5250

53-
.. warning::
54-
55-
The message factory parameter is mandatory if the discovery layer is not installed.
56-
5751
Be Aware
5852
--------
5953

clients/cakephp-adapter.rst

+2-7
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ not yet included in your project), run:
1313
1414
$ composer require php-http/cakephp-adapter
1515
16-
.. include:: includes/install-message-factory.inc
17-
18-
.. include:: includes/install-discovery.inc
19-
2016
Usage
2117
-----
2218

@@ -33,9 +29,8 @@ like::
3329
Then create the adapter::
3430

3531
use Http\Adapter\Cake\Client as CakeAdapter;
36-
use Http\Message\MessageFactory\GuzzleMessageFactory;
3732

38-
$adapter = new CakeAdapter($cakeClient, new GuzzleMessageFactory());
33+
$adapter = new CakeAdapter($cakeClient);
3934

4035
.. note::
4136

@@ -53,6 +48,6 @@ Or if you installed the :doc:`discovery </discovery>` layer::
5348

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

56-
.. include:: includes/further-reading-sync.inc
51+
.. include:: includes/further-reading-async.inc
5752

5853
.. _CakePHP HTTP client: https://book.cakephp.org/3.0/en/core-libraries/httpclient.html

clients/curl-client.rst

+7-11
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,26 @@ To install the cURL client, run:
1212
1313
$ composer require php-http/curl-client
1414
15-
.. include:: includes/install-message-factory.inc
16-
17-
.. include:: includes/install-discovery.inc
18-
1915
Usage
2016
-----
2117

22-
The cURL client needs a :ref:`message factory <message-factory>` and a
23-
:ref:`stream factory <stream-factory>` in order to to work. You can either specify the factory
24-
explicitly::
18+
The cURL client needs a PSR-17 message factory and stream factory to work.
19+
You can either specify the factory explicitly::
2520

2621
use Http\Client\Curl\Client;
2722
use Http\Message\MessageFactory\DiactorosMessageFactory;
2823
use Http\Message\StreamFactory\DiactorosStreamFactory;
2924

3025
$client = new Client(new DiactorosMessageFactory(), new DiactorosStreamFactory());
3126

32-
Or you can use :doc:`../discovery`::
27+
Or you can omit the parameters and let the client use :doc:`../discovery` to
28+
determine a suitable factory::
3329

3430
use Http\Client\Curl\Client;
3531
use Http\Discovery\MessageFactoryDiscovery;
3632
use Http\Discovery\StreamFactoryDiscovery;
3733

38-
$client = new Client(MessageFactoryDiscovery::find(), StreamFactoryDiscovery::find());
34+
$client = new Client();
3935

4036
Configuring Client
4137
------------------
@@ -49,7 +45,7 @@ You can use `cURL options <http://php.net/curl_setopt>`_ to configure Client::
4945
$options = [
5046
CURLOPT_CONNECTTIMEOUT => 10, // The number of seconds to wait while trying to connect.
5147
];
52-
$client = new Client(MessageFactoryDiscovery::find(), StreamFactoryDiscovery::find(), $options);
48+
$client = new Client(null, null, $options);
5349

5450
The following options can not be changed in the set up. Most of them are to be provided with the
5551
request instead:
@@ -65,4 +61,4 @@ request instead:
6561
* CURLOPT_URL
6662
* CURLOPT_USERPWD
6763

68-
.. include:: includes/further-reading-sync.inc
64+
.. include:: includes/further-reading-async.inc

clients/guzzle5-adapter.rst

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
Guzzle5 Adapter
2-
===============
1+
Guzzle5 Adapter (deprecated)
2+
============================
33

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

6+
This adapter only implements the PHP-HTTP synchronous interface. This interface
7+
has been superseded by PSR-18.
8+
9+
Guzzle 5 is very old and `not maintained anymore`_. We recommend to upgrade to
10+
Guzzle version 7.
11+
612
Installation
713
------------
814

@@ -13,10 +19,6 @@ not yet included in your project), run:
1319
1420
$ composer require php-http/guzzle5-adapter
1521
16-
.. include:: includes/install-message-factory.inc
17-
18-
.. include:: includes/install-discovery.inc
19-
2022
Usage
2123
-----
2224

@@ -50,3 +52,4 @@ Or if you installed the :doc:`discovery </discovery>` layer::
5052
.. include:: includes/further-reading-sync.inc
5153

5254
.. _Guzzle 5 HTTP client: http://docs.guzzlephp.org/en/5.3/
55+
.. _not maintained anymore: https://github.com/guzzle/guzzle#version-guidance

clients/guzzle7-adapter.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ Guzzle 7 Adapter
22
================
33

44
An HTTPlug adapter for the `Guzzle 7 HTTP client`_. Guzzle 7 supports PSR-18
5-
out of the box. This adapter makes sense if you want to use HTTPlug async interface or to use
6-
Guzzle 7 with a library that did not upgrade to PSR-18 yet and depends on ``php-http/client-implementation``.
5+
out of the box. This adapter makes sense if you want to use HTTPlug async
6+
interface or to use Guzzle 7 with a library that did not upgrade to PSR-18 yet
7+
and depends on ``php-http/client-implementation``.
78

89
Installation
910
------------

clients/includes/install-discovery.inc

-6
This file was deleted.

clients/includes/install-message-factory.inc

-21
This file was deleted.

clients/mock-client.rst

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
Mock Client
22
===========
33

4-
54
The mock client is a special type of client. It is a test double that does not
65
send the requests that you pass to it, but collects them instead. You can then
76
retrieve those request objects and make assertions about them. Additionally, you

clients/react-adapter.rst

-4
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ dependency.
1313
1414
$ composer require php-http/react-adapter
1515
16-
.. include:: includes/install-message-factory.inc
17-
18-
.. include:: includes/install-discovery.inc
19-
2016
Usage
2117
-----
2218

clients/socket-client.rst

+34-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
Socket Client
2-
=============
1+
Socket Client (deprecated)
2+
==========================
33

44
The socket client uses the stream extension from PHP, which is integrated into
55
the core.
66

7+
This client only implements the PHP-HTTP synchronous interface, which has been
8+
superseded by PSR-18. Use one of the PSR-18 clients instead.
9+
710
Features
811
--------
912

@@ -21,7 +24,23 @@ To install the Socket client, run:
2124
2225
$ composer require php-http/socket-client
2326
24-
.. include:: includes/install-message-factory.inc
27+
This client does not come with a PSR-7 implementation out of the box, so you have
28+
to install one as well (for example `Guzzle PSR-7`_):
29+
30+
.. code-block:: bash
31+
32+
$ composer require guzzlehttp/psr7
33+
34+
In order to provide full interoperability, message implementations are accessed
35+
through :ref:`factories <message-factory>`. Message factories for
36+
`Laminas Diactoros`_ (and its abandoned predecessor `Zend Diactoros`_),
37+
`Guzzle PSR-7`_ and `Slim PSR-7`_ are available in the
38+
:doc:`message </message>` component:
39+
40+
.. code-block:: bash
41+
42+
$ composer require php-http/message
43+
2544
2645
Usage
2746
-----
@@ -49,8 +68,8 @@ The available options are:
4968
:write_buffer_size: When sending the request we need to buffer the body, this option specify the size of this buffer, default is 8192,
5069
if you are sending big file with your client it may be interesting to have a bigger value in order to increase performance.
5170

52-
As an example someone may want to pass a client certificate when using the ssl, a valid configuration for this
53-
use case would be::
71+
As an example someone may want to pass a client certificate when using the ssl,
72+
a valid configuration for this use case would be::
5473

5574
use Http\Client\Socket\Client;
5675

@@ -65,13 +84,20 @@ use case would be::
6584

6685
.. warning::
6786

68-
This client assumes that the request is compliant with HTTP 2.0, 1.1 or 1.0 standard. So a request without a ``Host`` header, or
69-
with a body but without a ``Content-Length`` will certainly fail.
70-
To make sure all requests will be sent out correctly, we recommend to use the ``PluginClient`` with the following plugins:
87+
This client assumes that the request is compliant with HTTP 2.0, 1.1 or 1.0
88+
standard. So a request without a ``Host`` header, or with a body but
89+
without a ``Content-Length`` will certainly fail. To make sure all requests
90+
will be sent out correctly, we recommend to use the ``PluginClient`` with
91+
the following plugins:
7192

7293
* ``ContentLengthPlugin`` sets the correct ``Content-Length`` header, or decorate the stream to use chunked encoding
7394
* ``DecoderPlugin`` decodes encoding coming from the response (chunked, gzip, deflate and compress)
7495

7596
:doc:`Read more on plugins </plugins/introduction>`
7697

7798
.. include:: includes/further-reading-sync.inc
99+
100+
.. _Guzzle PSR-7: https://github.com/guzzle/psr7
101+
.. _Laminas Diactoros: https://github.com/laminas/laminas-diactoros
102+
.. _Slim PSR-7: https://github.com/slimphp/Slim-Psr7
103+
.. _Zend Diactoros: https://github.com/zendframework/zend-diactoros

clients/symfony-client.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ To install the Symfony client, run:
1212
1313
$ composer require symfony/http-client
1414
15-
This client does not come with a PSR-7 implementation out of the box, so you have
16-
to install one as well. `Nyholm PSR-7`_ is supported natively:
15+
This client does not come with a PSR-7 implementation out of the box. If you do
16+
not require one, `discovery <../discovery>` will install `Nyholm PSR-7`_. If
17+
you do not allow the composer plugin of the ``php-http/discovery`` component,
18+
you need to install a PSR-7 implementation manually:
1719

1820
.. code-block:: bash
1921
2022
$ composer require nyholm/psr7
2123
22-
.. include:: includes/install-discovery.inc
23-
2424
Usage
2525
-----
2626
.. code-block:: php

clients/zend-adapter.rst

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1-
Zend Adapter
2-
============
1+
Zend Adapter (deprecated)
2+
=========================
33

44
An HTTPlug adapter for the Zend HTTP client.
55

6+
Zend framework meanwhile has been renamed to Laminas, and the client is no
7+
longer maintained.
8+
9+
This adapter only implements the PHP-HTTP synchronous interface. This interface
10+
has been superseded by PSR-18, which the `Laminas Diactoros`_ implements
11+
directly.
12+
613
Installation
714
------------
815

@@ -13,11 +20,4 @@ not yet included in your project), run:
1320
1421
$ composer require php-http/zend-adapter
1522
16-
.. include:: includes/install-message-factory.inc
17-
18-
.. include:: includes/install-discovery.inc
19-
20-
Usage
21-
-----
22-
23-
To be written...
23+
.. _Laminas Diactoros: https://docs.laminas.dev/laminas-diactoros/

message.rst

-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,4 @@ This package contains various PSR-7 tools which might be useful in an HTTP workf
1111
* Authentication method implementations
1212
* Various Stream encoding tools
1313
* Message decorators
14-
* Message factory implementations for Guzzle PSR-7, Diactoros and Slim Framework.
15-
* Stream and URI factory implementations for Guzzle PSR-7 and Diactoros
1614
* Cookie implementation

0 commit comments

Comments
 (0)