symfony/psr-http-message-bridge
Symfony PSR-7 Bridge integrates PSR-7 HTTP messages with Symfony. Convert between Symfony HttpFoundation requests/responses and PSR-7 implementations, enabling interoperability with PSR-7 middleware, libraries, and frameworks.
Illuminate\Http and PSR-7 (e.g., Symfony’s HttpFoundation or middleware like zendframework/zend-diactoros). This aligns with modern Laravel architectures adopting PSR-15 middleware (e.g., fruitcake/laravel-psr) or integrating Symfony components (e.g., HTTP client, Messenger).Request/Response and PSR-7 objects (e.g., wrapping the bridge in a service).symfony/http-foundation), which may conflict with the bridge’s version. Mitigation: Use a dedicated service container (e.g., symfony/service-container) or isolate the bridge in a microservice.brick/brick, php-http/message), enabling shared middleware layers across Laravel and Symfony.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Dependency Conflicts | High | Pin Symfony components to exact versions; use a separate container for the bridge. |
| Cookie/Stream Issues | Medium | Test with partitioned cookies, large payloads, and custom headers. |
| Laravel-Specific Quirks | Medium | Validate interactions with Laravel’s Request (e.g., files, server params). |
| Performance Overhead | Low | Benchmark conversion latency; caching may help for high-throughput APIs. |
| Long-Term Maintenance | Low | Symfony’s PSR-7 bridge is stable; align updates with Laravel’s Symfony version. |
fruitcake/laravel-psr may suffice.symfony/http-foundation).HttpFoundation and PSR-7? If not, onboarding may introduce friction.Illuminate\Http\Request/Response and PSR-7 for shared middleware or APIs.zendframework/zend-diactoros) across Laravel and Symfony services.fruitcake/laravel-psr: Lighter-weight PSR-15 support without Symfony integration.brick/brick).symfony/http-foundation).Request/Response ↔ PSR-7.replace or conflict directives to avoid Symfony version clashes.symfony/service-container) for the bridge.| Component | Compatibility Notes |
|---|---|
| Laravel 8–10 | Works with Symfony 5.4–8.x; validate version alignment with Laravel’s bundled components. |
| PHP 8.1–8.4 | Symfony 6+ requires PHP 8.1+; Symfony 8 requires PHP 8.4+. |
| PSR-15 Middleware | Fully compatible with any PSR-15 middleware (e.g., zendframework/zend-diactoros). |
| Symfony Components | Enables integration with Symfony’s HTTP client, Messenger, etc. |
| Laravel Middleware | Requires custom adapters to convert between Illuminate\Http and PSR-7. |
| Testing Frameworks | Useful for mocking PSR-7 objects in Laravel tests (e.g., PestPHP, PHPUnit). |
composer require symfony/psr-http-message-bridge
composer.json constraints).Psr7BridgeService):
use Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory;
use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory;
class Psr7BridgeService {
public function toPsr7(Request $request): ServerRequestInterface {
return (new DiactorosFactory())->createRequest($request);
}
public function toLaravel(ServerRequestInterface $request): Request {
return (new HttpFoundationFactory())->createRequest($request);
}
}
fruitcake/laravel-psr):
$app->middleware(\App\Middleware\Psr15AuthMiddleware::class);
How can I help you explore Laravel packages today?