@@ -3,12 +3,6 @@ Discovery
3
3
4
4
The discovery service allows to find and use installed resources.
5
5
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
-
12
6
Consumers of libraries using discovery still need to make sure they install one of the implementations.
13
7
Discovery can only find installed code, not fetch code from other sources.
14
8
@@ -22,36 +16,63 @@ Currently available discovery services:
22
16
23
17
The principle is always the same: you call the static ``find `` method on the discovery service if no explicit
24
18
implementation 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
+
26
40
27
41
Installation
28
42
------------
29
43
44
+ .. code-block :: bash
45
+
46
+ $ composer require php-http/discovery
47
+
48
+
49
+ Using Puli
50
+ ^^^^^^^^^^
51
+
30
52
There are two kinds of installation:
31
53
32
54
- In a reusable library
33
55
- In an application
34
56
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.
40
60
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:
44
62
45
63
.. code-block :: bash
46
64
47
- $ composer require puli/composer-plugin
65
+ $ composer require puli/composer-plugin
66
+
48
67
49
68
If you need the composer-plugin for testing in a reusable library, make it a development dependency instead:
50
69
51
70
.. code-block :: bash
52
71
53
- $ composer require --dev puli/composer-plugin
72
+ $ composer require --dev puli/composer-plugin
54
73
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.
55
76
56
77
Read more about setting up Puli in their `official documentation `_.
57
78
0 commit comments