Skip to content

Commit 9a867f8

Browse files
committed
Update plugin documentation
1 parent 92cd365 commit 9a867f8

17 files changed

+109
-54
lines changed

_static/custom.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
.row-even .line-block, .row-odd .line-block {
22
margin-left: 0;
33
}
4+
5+
.versionmodified {
6+
font-weight: bold;
7+
}

components/client-common.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,8 @@ If one or more of the requests throw exceptions, they are added to the
7676
} catch (BatchException $e) {
7777
var_dump($e->getResult()->getExceptions());
7878
}
79+
80+
PluginClient
81+
------------
82+
83+
See :doc:`/plugins/introduction`

index.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ Packages
3737

3838
PHP-HTTP offers several packages:
3939

40-
=============== =========================================================== =============================
40+
=============== =========================================================== ====================================
4141
Type Description Namespace
42-
=============== =========================================================== =============================
42+
=============== =========================================================== ====================================
4343
Clients HTTP clients: Socket, cURL and others ``Http\Client\[Name]``
4444
Client adapters Adapters for other clients: Guzzle, React and others ``Http\Adapter\[Name]``
45-
Plugins Implementation-independent authentication, cookies and more ``Http\Client\Plugin\[Name]``
46-
=============== =========================================================== =============================
45+
Plugins Implementation-independent authentication, cookies and more ``Http\Client\Common\Plugin\[Name]``
46+
=============== =========================================================== ====================================
4747

4848
Read more about :doc:`clients and adapters <clients>` and :doc:`plugins <plugins/index>`.
4949

plugins/authentication.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ from ``php-http/message`` to authenticate requests sent through the client::
66

77
use Http\Discovery\HttpClientDiscovery;
88
use Http\Message\Authentication\BasicAuth;
9-
use Http\Client\Plugin\PluginClient;
10-
use Http\Client\Plugin\AuthenticationPlugin;
9+
use Http\Client\Common\PluginClient;
10+
use Http\Client\Common\Plugin\AuthenticationPlugin;
1111

1212
$authentication = new BasicAuth('username', 'password');
1313
$authenticationPlugin = new AuthenticationPlugin($authentication);

plugins/build-your-own.rst

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ Building Custom Plugins
44
When writing your own Plugin, you need to be aware that the Plugin Client is async first.
55
This means that every plugin must be written with Promises. More about this later.
66

7-
Each plugin must implement the ``Http\Client\Plugin\Plugin`` interface.
7+
Each plugin must implement the ``Http\Client\Common\Plugin`` interface.
8+
9+
.. versionadded:: 1.1
10+
The plugins were moved to the `client-common` package in version 1.1.
11+
If you work with version 1.0, the interface is called ``Http\Client\Plugin\Plugin`` and
12+
you need to require the separate `php-http/plugins` package.
13+
The old interface will keep extending ``Http\Client\Common\Plugin``, but relying on it is deprecated.
814

915
This interface defines the ``handleRequest`` method that allows to modify behavior of the call::
1016

@@ -84,18 +90,18 @@ You can manipulate the ``ResponseInterface`` or the ``Exception`` by using the
8490
deprecate the old contract.
8591

8692
To better understand the whole process check existing implementations in the
87-
`plugin repository`_.
93+
`client-common package`_.
8894

8995
Contributing Your Plugins to PHP-HTTP
9096
-------------------------------------
9197

92-
We are open to contributions. If the plugin is of general interest and is not too complex, the best
93-
is to do a Pull Request to ``php-http/plugins``. Please see the :doc:`contribution guide <../development/contributing>`.
98+
We are open to contributions. If the plugin is of general interest, is not too complex and does not have dependencies, the best
99+
is to do a Pull Request to ``php-http/client-common``. Please see the :doc:`contribution guide <../development/contributing>`.
94100
We don't promise that every plugin gets merged into the core. We need to keep the core as small as
95101
possible with only the most widely used plugins to keep it maintainable.
96102

97103
The alternative is providing your plugins in your own repository. Please let us know when you do,
98104
we would like to add a list of existing third party plugins to the list of plugins.
99105

100106
.. _PSR: https://groups.google.com/forum/?fromgroups#!topic/php-fig/wzQWpLvNSjs
101-
.. _plugin repository: https://github.com/php-http/plugins
107+
.. _client-common package: https://github.com/php-http/client-common

plugins/cache.rst

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
Cache Plugin
22
============
33

4+
Install
5+
-------
6+
7+
.. code-block:: bash
8+
9+
$ composer require php-http/cache-plugin
10+
11+
Usage
12+
-----
13+
414
The ``CachePlugin`` allows you to cache responses from the server. It can use
515
any PSR-6 compatible caching engine. By default, the plugin respects the cache
616
control headers from the server as specified in :rfc:`7234`. It needs a
717
:ref:`stream <stream-factory>` and a `PSR-6`_ implementation::
818

919
use Http\Discovery\HttpClientDiscovery;
10-
use Http\Client\Plugin\PluginClient;
11-
use Http\Client\Plugin\CachePlugin;
20+
use Http\Client\Common\PluginClient;
21+
use Http\Client\Common\Plugin\CachePlugin;
1222

1323
/** @var \Psr\Cache\CacheItemPoolInterface $pool */
1424
$pool...

plugins/content-length.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ The ``ContentLengthPlugin`` sets the correct ``Content-Length`` header value bas
55
request. This helps HTTP servers to handle the request::
66

77
use Http\Discovery\HttpClientDiscovery;
8-
use Http\Client\Plugin\PluginClient;
9-
use Http\Client\Plugin\ContentLengthPlugin;
8+
use Http\Client\Common\PluginClient;
9+
use Http\Client\Common\Plugin\ContentLengthPlugin;
1010

1111
$contentLengthPlugin = new ContentLengthPlugin();
1212

plugins/cookie.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ to :rfc:`6265#section-4` specification::
66

77
use Http\Discovery\HttpClientDiscovery;
88
use Http\Message\CookieJar;
9-
use Http\Client\Plugin\PluginClient;
10-
use Http\Client\Plugin\CookiePlugin;
9+
use Http\Client\Common\PluginClient;
10+
use Http\Client\Common\Plugin\CookiePlugin;
1111

1212
$cookiePlugin = new CookiePlugin(new CookieJar());
1313

plugins/decoder.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ The ``DecoderPlugin`` decodes the body of the response with filters coming from
55
or ``Content-Encoding`` headers::
66

77
use Http\Discovery\HttpClientDiscovery;
8-
use Http\Client\Plugin\PluginClient;
9-
use Http\Client\Plugin\DecoderPlugin;
8+
use Http\Client\Common\PluginClient;
9+
use Http\Client\Common\Plugin\DecoderPlugin;
1010

1111
$decoderPlugin = new DecoderPlugin();
1212

plugins/error.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ Error Plugin
33

44
The ``ErrorPlugin`` transforms responses with HTTP error status codes into exceptions:
55

6-
* 400-499 status code are transformed into ``Http\Client\Plugin\Exception\ClientErrorException``;
7-
* 500-599 status code are transformed into ``Http\Client\Plugin\Exception\ServerErrorException``
6+
* 400-499 status code are transformed into ``Http\Client\Common\Exception\ClientErrorException``;
7+
* 500-599 status code are transformed into ``Http\Client\Common\Exception\ServerErrorException``
88

99
Both exceptions extend the ``Http\Client\Exception\HttpException`` class, so you can fetch the request
1010
and the response coming from them::
1111

1212
use Http\Discovery\HttpClientDiscovery;
13-
use Http\Client\Plugin\PluginClient;
14-
use Http\Client\Plugin\ErrorPlugin;
15-
use Http\Client\Plugin\Exception\ClientErrorException;
13+
use Http\Client\Common\PluginClient;
14+
use Http\Client\Common\Plugin\ErrorPlugin;
15+
use Http\Client\Common\Exception\ClientErrorException;
1616

1717
$errorPlugin = new ErrorPlugin();
1818

0 commit comments

Comments
 (0)