psr/http-client
PSR-18 interfaces and common code for HTTP clients in PHP. This package provides the standard abstractions (requests, responses, exceptions) for interoperability, not an actual client implementation. Find compatible implementations on Packagist.
Architecture fit: PSR-18 interfaces align perfectly with Laravel's dependency injection and service container patterns. It enables consistent HTTP client contracts across microservices and third-party integrations without vendor-specific code, reducing cross-service coupling. Laravel's built-in Http facade and HttpClient class already implement this standard, making it a natural fit for the ecosystem.
Integration feasibility: High. Requires only composer require psr/http-client plus a concrete implementation (e.g., symfony/http-client). Laravel automatically binds PSR-18 clients via the container (app(ClientInterface::class)), eliminating manual wiring.
Technical risk: Low for standardization but high for misconfiguration. The package provides only interfaces—no implementation—so teams often mistakenly install it without a concrete client, causing runtime failures. Version compatibility with PSR-7 (1.x vs 2.x) requires careful client selection.
Key questions: Which concrete implementation (Symfony HttpClient vs Guzzle) best balances our middleware, retry, and performance needs? How will we handle PSR-7 version mismatches across Laravel versions? What exception-handling patterns will standardize across all integrations?
Stack fit: Native compatibility with Laravel 8+. The Http facade (Http::get(), Http::post()) and HttpClient class are PSR-18-compliant by default. New projects should inject ClientInterface directly for granular control, while legacy Guzzle/Symfony usage can be refactored via container binding.
Migration path: For existing code: 1) Replace direct Guzzle/Symfony usage with ClientInterface injection; 2) Bind concrete client (e.g., symfony/http-client) in service provider; 3) Use Http::sendRequest() for raw PSR-18 responses. For new features: Always depend on interfaces, not concrete clients.
Compatibility: Works with Laravel 11+ (PSR-7 2.x) and Laravel 8-10 (PSR-7 1.x). Must pair with compatible implementations: Symfony HttpClient (v6+), Guzzle 7+ with guzzlehttp/psr7 bridge, or php-http/guzzle7-adapter.
Sequencing: 1) Install psr/http-client + chosen implementation (e.g., symfony/http-client); 2) Configure container binding in AppServiceProvider; 3) Refactor integration layers to use ClientInterface/RequestFactoryInterface; 4) Test with Http::sendRequest() for raw PSR-18 responses.
Maintenance: Minimal overhead for the interface itself (stable PSR standard). Concrete implementations (e.g., Symfony HttpClient) require version management, but the interface insulates core code from breaking changes. Documentation must emphasize "interface-only" nature to prevent common misconfigurations.
Support: Strong community support via PSR standards and Laravel docs. Initial support load may spike from confusion about "no runtime code"—requires clear internal documentation and training on the interface/implementation distinction.
Scaling: No
How can I help you explore Laravel packages today?