@@ -3,12 +3,6 @@ Discovery
33
44The discovery service allows to find and use installed resources.
55
6- Under the hood it uses `Puli `_ for the discovery logic. All of our packages provide Puli resources.
7- Discovery is simply a convenience wrapper to statically access clients and factories for when
8- Dependency Injection is not an option. Discovery is useful in libraries that want to offer
9- zero-configuration services relying on the virtual packages. If you have Dependency Injection available,
10- using Puli directly is more elegant (see for example the Symfony HttplugBundle).
11-
126Consumers of libraries using discovery still need to make sure they install one of the implementations.
137Discovery can only find installed code, not fetch code from other sources.
148
@@ -22,36 +16,63 @@ Currently available discovery services:
2216
2317The principle is always the same: you call the static ``find `` method on the discovery service if no explicit
2418implementation was specified. The discovery service will try to locate a suitable implementation.
25- If no implementation is found, an ``Http\Discovery\NotFoundException `` is thrown.
19+ If no implementation is found, an ``Http\Discovery\Exception\NotFoundException `` is thrown.
20+
21+ .. versionadded :: 0.9
22+ The exception ``Http\Discovery\NotFoundException `` has been moved to ``Http\Discovery\Exception\NotFoundException ``.
23+
24+ Discovery is simply a convenience wrapper to statically access clients and factories for when
25+ Dependency Injection is not an option. Discovery is useful in libraries that want to offer
26+ zero-configuration services relying on the virtual packages.
27+
28+
29+ Strategies
30+ ----------
31+
32+ The package supports multiple discovery strategies and comes with two out-of-the-box:
33+
34+ - A builtin strategy with official HTTPlug components
35+ - A `Puli `_ strategy
36+
37+ Strategies provide candidates of a type which gets evaluated by the discovery service.
38+ When it finds the best candidate, it caches it and stops looking in further strategies.
39+
2640
2741Installation
2842------------
2943
44+ .. code-block :: bash
45+
46+ $ composer require php-http/discovery
47+
48+
49+ Using Puli
50+ ^^^^^^^^^^
51+
3052There are two kinds of installation:
3153
3254- In a reusable library
3355- In an application
3456
35- In both cases you have to install the discovery package itself:
36-
37- .. code-block :: bash
38-
39- $ composer require php-http/discovery
57+ In both cases you have to install the discovery package itself and set up Puli.
58+ The easiest way is installing the composer-plugin which automatically configures
59+ all the composer packages to act as Puli modules.
4060
41- As mentioned above, discovery relies on Puli. In order to use discovery, you need to also set up Puli.
42- The easiest way is installing the composer-plugin which automatically configures all the composer packages to act as
43- Puli modules. For applications, simply do:
61+ For applications, simply do:
4462
4563.. code-block :: bash
4664
47- $ composer require puli/composer-plugin
65+ $ composer require puli/composer-plugin
66+
4867
4968 If you need the composer-plugin for testing in a reusable library, make it a development dependency instead:
5069
5170.. code-block :: bash
5271
53- $ composer require --dev puli/composer-plugin
72+ $ composer require --dev puli/composer-plugin
5473
74+ All of our packages provide Puli resources too, so if Puli is installed, discovery will use it as the primary strategy
75+ and fall back to the static list.
5576
5677Read more about setting up Puli in their `official documentation `_.
5778
0 commit comments