Skip to content

Commit 2778145

Browse files
committed
improve curl client doc
1 parent 1fa5cfb commit 2778145

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

clients/curl-client.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,24 @@ To install the cURL client, run:
1212
1313
$ composer require php-http/curl-client
1414
15-
Usage
16-
-----
17-
18-
The cURL client needs a :ref:`message <message-factory>` and a :ref:`stream <stream-factory>`
19-
factory in order to to work::
15+
.. include:: includes/install-message-factory.inc
2016

21-
use Http\Client\Curl\Client;
17+
.. include:: includes/install-discovery.inc
2218

23-
$client = new Client($messageFactory, $streamFactory);
19+
Usage
20+
-----
2421

25-
Using `php-http/message <https://packagist.org/packages/php-http/message>`_::
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::
2625

2726
use Http\Client\Curl\Client;
2827
use Http\Message\MessageFactory\DiactorosMessageFactory;
2928
use Http\Message\StreamFactory\DiactorosStreamFactory;
3029

3130
$client = new Client(new DiactorosMessageFactory(), new DiactorosStreamFactory());
3231

33-
Using `php-http/discovery <https://packagist.org/packages/php-http/discovery>`_::
32+
Or you can use :doc:`../discovery`::
3433

3534
use Http\Client\Curl\Client;
3635
use Http\Discovery\MessageFactoryDiscovery;
@@ -53,7 +52,8 @@ You can use `cURL options <http://php.net/curl_setopt>`_ to configure Client::
5352
];
5453
$client = new Client(MessageFactoryDiscovery::find(), StreamFactoryDiscovery::find(), $options);
5554

56-
These options cannot be used (will be overwritten by Client):
55+
The following options can not be changed in the set up. Most of them are to be provided with the
56+
request instead:
5757

5858
* CURLOPT_CUSTOMREQUEST
5959
* CURLOPT_FOLLOWLOCATION

discovery.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@ Discovery
22
=========
33

44
The discovery service allows to find and use installed resources.
5+
56
Under the hood it uses `Puli`_ for the discovery logic. All of our packages provide Puli resources.
67
Discovery is simply a convenience wrapper to statically access clients and factories for when
78
Dependency Injection is not an option. Discovery is useful in libraries that want to offer
89
zero-configuration services relying on the virtual packages. If you have Dependency Injection available,
910
using Puli directly is more elegant (see for example the Symfony HttplugBundle).
1011

12+
Consumers of libraries using discovery still need to make sure they install one of the implementations.
13+
Discovery can only find installed code, not fetch code from other sources.
14+
1115
Currently available discovery services:
1216

1317
- HTTP Client Discovery
@@ -32,7 +36,7 @@ In both cases you have to install the discovery package itself:
3236

3337
.. code-block:: bash
3438
35-
$ composer require php-http/discovery
39+
$ composer require php-http/discovery
3640
3741
As mentioned above, discovery relies on Puli. In order to use discovery, you need to also set up Puli.
3842
The easiest way is installing the composer-plugin which automatically configures all the composer packages to act as

0 commit comments

Comments
 (0)