HTTPlug Discovery
Auto-discovery and auto-installation of PSR-17, PSR-18, and HTTPlug HTTP implementations for PHP.
Repository Health
Technical Analysis
php-http/discovery (HTTPlug Discovery) lets PHP libraries and SDKs depend on HTTP client and message abstractions without hard-coding a concrete implementation. It finds whichever PSR-17 factories, PSR-18 clients, or HTTPlug adapters are already installed in the host application and returns them at runtime.
As a Composer plugin it can even auto-install a suitable implementation when none is present, so library authors can write against the standard interfaces and let the end user’s project decide which HTTP stack (Guzzle, Symfony HttpClient, and others) actually gets used. It is downloaded millions of times a month across the PHP ecosystem.
What You Get
- Static discovery for PSR-18 clients, PSR-17 factories, and HTTPlug async/sync clients
- A Composer plugin that can auto-install a compatible implementation when none exists
- A pluggable strategy system that ranks and selects among installed candidates
- A bundled
Psr17FactoryandPsr18Clientconvenience wrapper over discovered pieces - Framework-agnostic HTTP dependencies so your library never pins a specific client
Common Use Cases
- Writing an SDK that needs a PSR-18 HTTP client without forcing users onto a specific one
- Resolving request, response, and stream factories (PSR-17) provided by the host app
- Avoiding hard dependencies on Guzzle or Symfony HttpClient in a reusable library
- Auto-installing a working HTTP stack during Composer install for downstream projects
Under The Hood
Architecture - The core is ClassDiscovery.php, which drives a set of per-interface discovery classes (Psr18ClientDiscovery, Psr17FactoryDiscovery, HttpClientDiscovery, HttpAsyncClientDiscovery, and legacy factory finders) against a Strategy/ directory of ranked candidate strategies. A Composer/ subtree implements the composer-plugin hook that can inject and auto-install a compatible implementation during dependency resolution. Bundled Psr17Factory and Psr18Client wrappers compose the discovered pieces into ready-to-use objects. Tech Stack - Pure PHP supporting 7.1 through 8.x, integrating with the Composer plugin API (composer-plugin-api ^1.0|^2.0) and the PSR-7/17/18 and HTTPlug interface packages. Code Quality - The repository carries a substantial PHPUnit test suite (per-discovery tests plus dedicated Composer plugin tests) and is a long-established, widely-audited part of the php-http project. API Design - The public API is a handful of static find() calls with sensible defaults, so consuming an HTTP client is a one-liner while the strategy layer keeps the resolution logic extensible.