Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Psr Http Message Bridge

Psr Http Message Bridge Laravel Package

symfony/psr-http-message-bridge

Symfony PSR-7 Bridge integrates PSR-7 HTTP messages with Symfony's HttpFoundation, letting you convert requests and responses between the two in either direction. Useful for middleware and libraries built on PSR-7.

View on GitHub
Deep Wiki
Context7

PSR HTTP message bridge

Frequently asked questions about Psr Http Message Bridge
How do I install symfony/psr-http-message-bridge in a Laravel app?
Run composer require symfony/psr-http-message-bridge and install a PSR-7 implementation such as nyholm/psr7, since the bridge does not ship one. Laravel already includes symfony/http-foundation through Illuminate, so you usually do not need to add it separately. No Laravel service provider is required by the package; instantiate the bridge factories where needed or bind them in AppServiceProvider.
How do I convert a Laravel Request to a PSR-7 ServerRequest?
Use the bridge's PsrHttpFactory, configured with PSR-17 request, stream, and upload factories, then call createRequest on the Illuminate request. Laravel requests extend Symfony HttpFoundation Request, so the conversion works directly. To go the other way, use HttpFoundationFactory to turn a PSR-7 ServerRequest into a Symfony/Laravel request.
Can I run PSR-15 middleware inside Laravel with this bridge?
Yes, but the bridge only converts messages; it does not dispatch PSR-15 middleware for you. Write a Laravel middleware wrapper that converts the incoming request to PSR-7, passes it through your PSR-15 dispatcher, then converts the PSR-7 response back to a Laravel response. This lets you reuse compatible middleware while keeping Laravel's pipeline in control.
Does the bridge work with Illuminate\Http\Request and Illuminate\Http\Response?
Yes, because Laravel's request and response classes extend Symfony HttpFoundation, which is exactly what the bridge converts. Headers, body streams, uploaded files, and server parameters are carried across the conversion. Test custom cookie and large-upload behavior if your app relies on edge cases, since those areas can differ between implementations.
Which PSR-7 implementations can I use with symfony/psr-http-message-bridge?
The bridge works with any PSR-7 implementation, including Nyholm PSR-7, Laminas Diactoros, and Guzzle PSR-7. You must install that implementation yourself; it is not bundled. If you use PsrHttpFactory, also provide PSR-17 factories, which many PSR-7 packages include.
Do I need a service provider or config file for this package in Laravel?
No, the bridge has no Laravel-specific service provider or config file. It is a standalone Symfony component that you instantiate directly or bind into Laravel's container. Put shared factory setup in AppServiceProvider so middleware, clients, and tests can resolve the same configuration.
Is symfony/psr-http-message-bridge production-ready for Laravel APIs?
Yes, it is maintained by the Symfony project and is widely used for HttpFoundation-to-PSR-7 integration. The conversion adds only microsecond-level overhead, but you should benchmark high-throughput endpoints and avoid unnecessary round trips. Validate cookie handling, file uploads, and streamed responses in staging before relying on it heavily.
What is the difference between this bridge and nyholm/psr7 or Guzzle?
Nyholm PSR-7 and Guzzle provide PSR-7 message implementations and clients, while this bridge translates between those PSR-7 messages and Symfony HttpFoundation. In a Laravel app you often install both: the bridge for conversion and a PSR-7 implementation for the actual message objects. If you only need outgoing HTTP calls, Laravel's HTTP client may be simpler than adding a PSR-7 stack.
How should I test PSR-7 conversions in a Laravel application?
Create Laravel requests with Request::create or your test helpers, convert them through PsrHttpFactory, and assert the PSR-7 headers, body, and uploaded files. Use PSR-7 test doubles from Nyholm or Guzzle to test the reverse conversion with HttpFoundationFactory. Also unit test the middleware glue that dispatches PSR-15 middleware so conversion failures are caught before integration tests.
Is symfony/psr-http-message-bridge maintained, and which Laravel versions are supported?
The package is maintained as part of Symfony and receives releases alongside Symfony components. There is no Laravel-specific version matrix; Composer resolves it from your Laravel release's symfony/http-foundation and psr/http-message constraints. Check composer why-not symfony/psr-http-message-bridge if you hit conflicts, and pin compatible versions in production.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo
bernskioldmedia/laravel-harvest
bernskiold/laravel-data-scrubber
bernskiold/laravel-currency-converter
bernskiold/laravel-campaign-monitor
bernskioldmedia/laravel-autotranslate
siberfx/telegram-bot
roy-sandip/laravel-view-extended
gregsphotography/site-builder-core
roy-sandip/laravel-view
anodyne/blade-fluentui-icons
webx-ui/module-catalog-collections