psr-discovery/http-factory-implementations
Discovers a PSR-17 HTTP factory at runtime by scanning for well-known implementations and returning the first available instance. Ideal for libraries/SDKs that want PSR-17 support without hard dependencies or user configuration. PHP 8.2+.
RequestFactory, ResponseFactory) without forcing users to explicitly declare dependencies (e.g., guzzlehttp/psr7, laminas/laminas-diactoros). Reduces friction for developers integrating your product.psr-mock/http-factory-implementation) during unit tests, simplifying test setup and isolation. Aligns with CI/CD pipelines requiring zero-config mocking.nyholm/psr7 or zend-diactoros) without breaking compatibility. Critical for products targeting diverse ecosystems (e.g., Laravel, Symfony, standalone PHP).psr7 vs. diactoros).Adopt When:
guzzlehttp/psr7).guzzle to nyholm/psr7 should be trivial).Look Elsewhere If:
laminas/laminas-diactoros is supported). Use the implementation directly instead of discovery.guzzlehttp/psr7). Discovery adds unnecessary complexity."This package lets us build HTTP-dependent features (e.g., API clients, webhooks) without forcing users to adopt specific libraries. For example, a developer using our SDK could already have laminas/laminas-diactoros installed for their framework—our tool would auto-detect and use it, reducing onboarding friction. It also simplifies testing by automatically mocking HTTP factories in CI pipelines, cutting dev time. The MIT license and PHP-FIG alignment ensure long-term stability, while the lightweight design keeps our product’s footprint minimal. This is a low-risk way to future-proof our HTTP infrastructure."
*"This solves the ‘which PSR-17 library should we depend on?’ problem. Instead of forcing users to add guzzlehttp/psr7 to their projects, we let them use whatever they already have (or none, with graceful fallbacks). Key benefits:
psr-mock/http-factory-implementation if installed.prefer() or use() specific implementations via code.Use case: If we’re building a new API client or middleware layer, this lets us support PSR-17 without bloating dependencies. For example:*
// Auto-detects user’s PSR-17 factory (e.g., from Slim, Laminas, or Guzzle)
$request = Discover::httpRequestFactory()->createRequest('GET', '/api');
No need for if (class_exists(GuzzleHttp\Psr7\Factory\Psr17Factory)) sprawl."
*"This package aligns with our PSR-first strategy and reduces technical debt by:
psr/http-message interfaces, not implementations.guzzlehttp/psr7 for nyholm/psr7 without breaking changes.UploadedFileFactoryInterface and UriFactoryInterface (added in v1.1.0), covering more PSR-17 use cases.Tradeoff: Adds a minor abstraction layer, but the benefits for maintainability and user flexibility outweigh the cost. Recommended for any HTTP-related feature where implementation agnosticism is valuable."*
How can I help you explore Laravel packages today?