Skip to content

Commit f1343eb

Browse files
committed
adjust documentation to PSR-17 and PSR-18, deprecate a couple of obsolete PHP-HTTP adapters and clients
1 parent 2356e9c commit f1343eb

15 files changed

+91
-124
lines changed

clients/artax-adapter.rst

Lines changed: 2 additions & 10 deletions
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

Lines changed: 6 additions & 12 deletions
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

Lines changed: 2 additions & 7 deletions
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

Lines changed: 7 additions & 11 deletions
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

Lines changed: 9 additions & 6 deletions
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

Lines changed: 3 additions & 2 deletions
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

Lines changed: 0 additions & 6 deletions
This file was deleted.

clients/includes/install-message-factory.inc

Lines changed: 0 additions & 20 deletions
This file was deleted.

clients/mock-client.rst

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 4 deletions
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

0 commit comments

Comments
 (0)