Skip to content

Commit 8bbdef4

Browse files
author
Márk Sági-Kazár
committed
Update plugin documentation
1 parent 92cd365 commit 8bbdef4

16 files changed

+98
-54
lines changed

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: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ 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.
88

99
This interface defines the ``handleRequest`` method that allows to modify behavior of the call::
1010

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

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

8989
Contributing Your Plugins to PHP-HTTP
9090
-------------------------------------
9191

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

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

100100
.. _PSR: https://groups.google.com/forum/?fromgroups#!topic/php-fig/wzQWpLvNSjs
101-
.. _plugin repository: https://github.com/php-http/plugins
101+
.. _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

plugins/headers.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ However, if the header already is present, the request is left unchanged.
1313
.. code:: php
1414
1515
use Http\Discovery\HttpClientDiscovery;
16-
use Http\Plugins\PluginClient;
17-
use Http\Plugins\HeaderDefaultPlugin;
16+
use Http\Client\Common\PluginClient;
17+
use Http\Client\Common\Plugin\HeaderDefaultPlugin;
1818
1919
$defaultUserAgent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1';
2020
@@ -36,8 +36,8 @@ this plugin will have the given value for given header.
3636
.. code:: php
3737
3838
use Http\Discovery\HttpClientDiscovery;
39-
use Http\Plugins\PluginClient;
40-
use Http\Plugins\HeaderSetPlugin;
39+
use Http\Client\Common\PluginClient;
40+
use Http\Client\Common\Plugin\HeaderSetPlugin;
4141
4242
$userAgent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1';
4343
@@ -61,8 +61,8 @@ The plugin ``HeaderRemovePlugin`` allows to remove given headers from the reques
6161
.. code:: php
6262
6363
use Http\Discovery\HttpClientDiscovery;
64-
use Http\Plugins\PluginClient;
65-
use Http\Plugins\HeaderRemovePlugin;
64+
use Http\Client\Common\PluginClient;
65+
use Http\Client\Common\Plugin\HeaderRemovePlugin;
6666
6767
$userAgent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1';
6868
@@ -90,8 +90,8 @@ but if the request does not already have the given header, it will be added to t
9090
.. code:: php
9191
9292
use Http\Discovery\HttpClientDiscovery;
93-
use Http\Plugins\PluginClient;
94-
use Http\Plugins\HeaderAppendPlugin;
93+
use Http\Client\Common\PluginClient;
94+
use Http\Client\Common\Plugin\HeaderAppendPlugin;
9595
9696
$myIp = '100.100.100.100';
9797
@@ -116,9 +116,9 @@ The following example will force the ``User-Agent`` and the ``Accept`` header va
116116
.. code:: php
117117
118118
use Http\Discovery\HttpClientDiscovery;
119-
use Http\Plugins\PluginClient;
120-
use Http\Plugins\HeaderSetPlugin;
121-
use Http\Plugins\HeaderRemovePlugin;
119+
use Http\Client\Common\PluginClient;
120+
use Http\Client\Common\Plugin\HeaderSetPlugin;
121+
use Http\Client\Common\Plugin\HeaderRemovePlugin;
122122
123123
$userAgent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1';
124124

0 commit comments

Comments
 (0)