Weave Code
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

Psr7 Laravel Package

guzzlehttp/psr7

Full PSR-7 message implementation with rich stream support: multiple stream types and decorators (append, buffer, caching, etc.), plus helpers like query-string parsing. Installed via Composer and maintained with v2 for PHP 7.2.5+.

View on GitHub
Deep Wiki
Context7

PSR-7 HTTP message library

Frequently asked questions about Psr7
Why would I use guzzlehttp/psr7 in a Laravel project instead of Laravel’s built-in PSR-7 implementation?
This package offers advanced stream decorators (e.g., `CachingStream`, `BufferStream`) and utilities like query-string parsing that Laravel’s default implementation lacks. Use it for custom middleware, streaming APIs, or when you need specific decorators like `MultipartStream` for file uploads.
Does guzzlehttp/psr7 work with Laravel’s Http facade or GuzzleHttp\Client?
Yes, it’s fully compatible. Laravel’s Http facade and GuzzleHttp\Client already depend on PSR-7, and this package acts as a drop-in replacement or extension. No configuration changes are needed for basic HTTP requests.
What Laravel versions support guzzlehttp/psr7 v2?
Laravel 8+ fully supports this package since it uses PHP 7.2.5+ (the package’s minimum requirement). Laravel 7.x may work but isn’t officially tested. Always check your Laravel version’s PHP compatibility first.
How do I mock HTTP requests/responses in Laravel tests using this package?
Use `Psr7\Utils::streamFor()` to create fake streams or `Psr7\Stream` classes to simulate request/response bodies. For example, mock a response body with `new Psr7\Stream(fopen('php://memory', 'r+'))` and write test data to it.
Will guzzlehttp/psr7 conflict with Laravel’s internal PSR-7 implementation?
No, it won’t conflict. Laravel’s `illuminate/http` package includes a PSR-7 implementation, but this package is a separate, interchangeable dependency. Composer will resolve the correct version automatically unless you explicitly force a conflict.
Are there performance concerns with stream decorators like CachingStream or BufferStream?
Decorators like `CachingStream` buffer data in memory or disk, which can impact performance for large files or high-throughput APIs. Use `BufferStream` with a high-water mark (e.g., 1024 bytes) to control memory usage, or avoid decorators for latency-sensitive operations.
Can I use guzzlehttp/psr7 for file uploads/downloads in Laravel?
Yes, it’s ideal for streaming file operations. Use `AppendStream` to concatenate multiple files, `CachingStream` for non-seekable uploads (e.g., S3 multipart uploads), or `StreamInterface` to handle chunked downloads efficiently with Laravel’s Storage facade.
What’s the difference between guzzlehttp/psr7 and symfony/http-foundation?
This package is a lightweight, PSR-7-focused library with advanced stream decorators, while `symfony/http-foundation` includes broader HTTP utilities (e.g., cookies, sessions). Use this package if you only need PSR-7 compliance and stream flexibility; use Symfony for full-stack HTTP features.
How do I upgrade from guzzlehttp/psr7 v1 to v2 in Laravel?
Run `composer require guzzlehttp/psr7:^2.0` and update your code to use the new namespace (`GuzzleHttp\Psr7` instead of `GuzzleHttp\Psr7\Message`). Check the [UPGRADING.md](https://github.com/guzzle/psr7/blob/master/UPGRADING.md) guide for breaking changes, but v2 is mostly backward-compatible.
Does guzzlehttp/psr7 support WebSockets or Server-Sent Events (SSE) in Laravel?
Yes, its stream abstractions are perfect for WebSocket or SSE payloads. Use `StreamInterface` to handle chunked data streams, and decorators like `AppendStream` to combine multiple messages. Pair it with Laravel’s Echo or custom middleware for real-time features.
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.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony