@@ -39,51 +39,13 @@ PHP-HTTP offers two types of clients that implement the above interfaces:
3939 Ideally, all HTTP client libraries out there will implement the HTTPlug
4040 interfaces. At that point, our adapters will no longer be necessary.
4141
42- Usage in an application
43- -----------------------
42+ Usage
43+ -----
4444
45- When writing an application, you need to require a concrete implementation.
45+ There are two main use cases for HTTPlug:
4646
47- See :doc: `virtual-package ` for more information on the topic of working with HTTPlug implementations.
48-
49- Installation in a reusable package
50- ----------------------------------
51-
52- In many cases, packages are designed to be reused from the very beginning.
53- For example, API clients are usually used in other packages/applications, not on their own.
54-
55- Reusable packages should **not rely on a concrete implementation ** (like Guzzle 6),
56- but only require any implementation of HTTPlug. HTTPlug uses the concept of virtual packages.
57- Instead of depending on only the interfaces, which would be missing an implementation,
58- or depending on one concrete implementation, you should depend on the virtual package ``php-http/client-implementation ``
59- or ``php-http/async-client-implementation ``. There is no package with that name,
60- but all clients and adapters implementing HTTPlug declare that they provide one of this virtual package or both.
61-
62- You need to edit the ``composer.json `` of your package to add the virtual package.
63- For development (installing the package standalone, running tests),
64- add a concrete implementation in the ``require-dev `` section to make the project installable:
65-
66- .. code-block :: json
67-
68- {
69- "require" : {
70- "php-http/client-implementation" : " ^1.0"
71- },
72- "require-dev" : {
73- "php-http/guzzle6-adapter" : " ^1.0"
74- },
75- }
76-
77- For extra convenience, you can use the :doc: `/discovery ` system to free the user of your
78- package from having to instantiate the client.
79- You should however always accept injecting the client instance to allow the user to configure the client as needed.
80- You can find an example in the :doc: `/discovery ` documentation.
81-
82- Users of your package will have to select a concrete adapter in their project to make your package installable.
83- Best point them to the :doc: `virtual-package ` page.
84-
85- To be able to send requests, you should not depend on a specific PSR-7 implementation,
86- but use the :ref: `message-factory ` system.
47+ * usage in an application that executes HTTP requests (see :doc: `application-developers `).
48+ * usage in a reusable package that executes HTTP requests (see :doc: `library-developers `).
8749
8850History
8951-------
0 commit comments