guzzlehttp/psr7
Full PSR-7 HTTP message implementation from Guzzle: request/response objects, URI and stream support, plus stream decorators (buffering, caching, appending, dropping) and utilities like query string parsing. Composer install; v2 supports PHP 7.2.5–8.5.
Illuminate\Http\Request, Illuminate\Http\Response) is built on PSR-7, ensuring seamless integration with core frameworks like:
CachingStream, LimitStream, InflateStream) align with Laravel’s need for:
Storage facade).InflateStream for gzipped responses).guzzlehttp/psr7 via:
guzzlehttp/guzzle (default HTTP client).symfony/http-foundation (Laravel’s HTTP layer).| Risk Area | Assessment | Mitigation Strategy |
|---|---|---|
| Version Conflicts | Laravel’s dependencies may pull older PSR-7 versions. | Pin to ^2.0 in composer.json to enforce compatibility. |
| Stream Performance | Decorators like CachingStream add memory overhead for large payloads. |
Use sparingly; prefer LimitStream for chunking or PumpStream for lazy loading. |
| Deprecations | Header::normalize() is deprecated (use splitList). |
Audit codebase for deprecated methods; update callsites. |
| PHP Version | Requires PHP ≥7.2.5 (Laravel 8+ meets this). | No action needed for modern Laravel apps. |
StreamDecoratorTrait to extend functionality.LimitStream or AppendStream for chunked processing.InflateStream simplifies decompression; ensure middleware supports it.CachingStream rewinding) be tested?
→ Use FnStream for mocking streams in unit tests.guzzlehttp/psr7 already included via Laravel’s dependencies?
→ Check composer why guzzlehttp/psr7 to avoid redundant installs.Illuminate\Http\Request implements Psr\Http\Message\RequestInterface.Illuminate\Http\Response implements Psr\Http\Message\ResponseInterface.guzzlehttp/psr7 internally; no changes needed.Storage facade (e.g., filesystem_disk) can leverage StreamInterface for:
LimitStream).MultipartStream).StreamInterface for:
InflateStream for decompression).PumpStream for lazy generation).| Scenario | Action | Example Use Case |
|---|---|---|
| New Laravel Project | No action; guzzlehttp/psr7 is auto-included via Laravel’s dependencies. |
Standard API requests/responses. |
| Custom Stream Logic | Compose decorators (e.g., FnStream, StreamDecoratorTrait). |
Logging stream reads/writes. |
| Legacy PSR-7 v1.x Code | Update to v2.x; check for deprecated methods (e.g., Header::normalize). |
Migrating from older Guzzle versions. |
| Performance Optimization | Replace CachingStream with LimitStream for large files. |
Chunked file uploads to S3. |
| Testing | Use FnStream to mock streams in PHPUnit tests. |
Testing file upload middleware. |
InflateStream (compression/decompression).StreamWrapper (mime-type detection).composer why guzzlehttp/psr7 to confirm inclusion.composer.json:
"require": {
"guzzlehttp/psr7": "^2.0"
}
Psr\Http\Message usages; ensure no custom PSR-7 implementations conflict.LimitStream for file uploads).StreamInterface (e.g., InflateStream in API responses).CachingStream vs. LimitStream for large payloads.CachingStream).StreamDecoratorTrait.guzzlehttp/psr7 for breaking changes (e.g., PHP 8.2+ support).Header::normalize() with splitList in custom code.CachingStream or NoSeekStream explicitly.CachingStream for unbounded streams; use LimitStream instead.InflateStream is used for gzipped responses.Message::bodySummary() for inspecting request/response bodies.Utils::hash() to verify stream integrity.CachingStream buffers entire streams in memory.LimitStream for chunked processing or PumpStream for lazy loading.$stream = new LimitStream($request->getStream(), 5 * 1024 * 1024); // 5MB chunks
How can I help you explore Laravel packages today?