symfony/psr-http-message-bridge
Symfony PSR-7 Bridge integrates PSR-7 HTTP messages with Symfony’s HttpFoundation. Convert requests and responses between PSR-7 implementations and Symfony components to ease interoperability with middleware and libraries.
HttpFoundation) with PSR-7 (Psr\Http\Message), enabling interoperability in Laravel (which uses Symfony’s HTTP components under the hood). This is a direct fit for Laravel’s middleware, request/response handling, and PSR-15/PSR-17 integrations (e.g., with frameworks like Slim, Laminas, or PSR-compliant APIs).symfony/http-foundation (e.g., Illuminate\Http\Request extends Symfony\Component\HttpFoundation\Request). This package unifies the ecosystem, reducing duplication and improving consistency.HttpClient (Guzzle-based) with PSR-18 clients.HttpFoundation.symfony/http-foundation (via illuminate/http), so this package adds no new dependencies—it’s a zero-cost abstraction layer.Symfony\Component\HttpFoundation\Response ↔ Psr\Http\Message\ResponseInterface).MockHttpFoundationRequest ↔ MockPsr7Request).Cookie class differs slightly from PSR-7’s CookieJarInterface. The bridge handles this, but custom cookie logic may need validation.UploadedFileInterface vs. Symfony’s UploadedFile—bridge supports both, but file streams may need explicit handling.ServerRequest (extending Symfony\Component\HttpFoundation\Request) is not a PSR-7 ServerRequestInterface. The bridge converts it, but middleware expecting strict PSR-7 may need adjustments.nyholm/psr7)? If so, how will this bridge affect test coverage?illuminate/http already pulls in symfony/http-foundation. Will this package introduce indirect dependencies (e.g., psr/http-message) that conflict with existing constraints?use Psr\Http\Server\RequestHandlerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
$psr7Request = $bridge->toPsr7($request); // Convert Laravel Request to PSR-7
$psr7Response = $psr15Middleware->process($psr7Request, $handler);
$laravelResponse = $bridge->toHttpFoundation($psr7Response); // Convert back
HttpClient (Guzzle-based) with PSR-18 clients for abstraction.Response::json()) with PSR-7 equivalents where needed.nyholm/psr7).psr/http-message and psr/http-factory are not pinned to conflicting versions.guzzlehttp/psr7 (if used).php-http/client) bridged via this package.MockServerRequest).psr/http-message and related interfaces, which may require version management.dd($bridge->toPsr7($request)->getBody()) to inspect conversions.Symfony\Component\HttpFoundation\Request).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Malformed PSR-7 request | Middleware crashes | Validate |
How can I help you explore Laravel packages today?