Skip to content

Add doc for auto-installation of missing implementations by Discovery #301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions discovery.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
Discovery
=========

The discovery service allows to find and use installed resources.

Consumers of libraries using discovery still need to make sure they install one of the implementations.
Discovery can only find installed code, not fetch code from other sources.
The discovery service allows to find installed resources and install missing ones.

Currently available discovery services:

Expand All @@ -28,6 +25,30 @@ Discovery is simply a convenience wrapper to statically access clients and facto
Dependency Injection is not an option. Discovery is useful in libraries that want to offer
zero-configuration services relying on the virtual packages.

Auto-installation
-----------------

.. versionadded:: 1.15
Auto-installation of missing dependencies is available since v1.15.

Discovery embeds a composer plugin that can auto-install missing implementations
when an application does not specify any specific implementation.

If a library requires both ``php-http/discovery`` and one of the supported virtual packages
(see :doc:`library-developers`), but no implementation for the virtual package is already
installed, the plugin will auto-install the best matching known implementation.

For example, if one is using ``react/event-loop``, the plugin will select ``php-http/react-adapter``
to meet a missing dependency on ``php-http/client-implementation``.

The following abstractions are currently supported:

- ``php-http/async-client-implementation``
- ``php-http/client-implementation``
- ``psr/http-client-implementation``
- ``psr/http-factory-implementation``
- ``psr/http-message-implementation``

.. _discovery-strategies:

Strategies
Expand Down