guzzlehttp/psr7
PSR-7 HTTP message implementation for PHP: request, response, URI, uploaded file, and stream objects compatible with Guzzle and any PSR-7 library. Create or inspect messages without sending requests; includes factories and helpers.
Illuminate\Http\Client) and framework components (e.g., Symfony\Component\HttpFoundation) rely on PSR-7 under the hood. This package ensures consistency with Laravel’s ecosystem.CachingStream, LimitStream, InflateStream, AppendStream) are invaluable for:
Http facade and Guzzle integration (via guzzlehttp/guzzle) already depend on PSR-7. This package is pre-installed in most Laravel projects via symfony/http-foundation or guzzlehttp/psr7.Utils::streamFor, Query::parse) that simplify testing HTTP interactions in Laravel’s unit/feature tests. The 3.2.0 fixes make decorator behavior deterministic and testable — previously, InflateStream and AppendStream could return short reads without surfacing the underlying source error.guzzlehttp/guzzle (v7+) bundles PSR-7. With 3.2.0 published, there is now a meaningful reason to be on a specific floor: any project relying on InflateStream or AppendStream should be on ≥ 3.2.0, or on a 2.x build only after confirming a backport of these two fixes.InflateStream ignored source read failures that followed successfully decoded bytes — i.e., a gzip stream could return a plausible-looking prefix, then swallow the error. This is a silent corruption path for compressed API responses or archived payloads.AppendStream discarded bytes read before a timeout — i.e., retry/resume logic built on concatenated streams could lose data at the seam with no exception.Header::normalize() is deprecated in favor of splitList(). Audit custom code using these methods (unchanged by 3.2.0).^3.x, or still on 2.x — and if 2.x, has the fix been backported? If not, is upgrading majors in scope now?guzzlehttp/psr7:^3.2) rather than a floating ^3.0, so these fixes can't be resolved away by a stale lockfile?InflateStream (gzip/deflate response decoding, archived payload reads) or AppendStream (retry/resume, multi-part concatenation) anywhere in our own code, or only transitively via Guzzle? Transitive-only usage is far lower risk.CachingStream/BufferStream impact latency/memory? Benchmark with real payloads.FnStream for runtime stream modifications? This complicates debugging and is not covered by the 3.2.0 fixes.Illuminate\Http\Client (uses PSR-7 under the hood).GuzzleHttp\Client (if using guzzlehttp/guzzle).Symfony\Component\HttpFoundation (bundled with Laravel).guzzlehttp/psr7 — with a floor, not a ceiling: ^3.2 if on 3.x; if on 2.x, pin to the specific patched build once the backport is confirmed. Replace the previously recommended blind ^2.6.guzzlehttp/guzzle, composer.json may already constrain PSR-7. Use composer why guzzlehttp/psr7 to check, then verify the resolved version actually satisfies the 3.2.0 floor — a constraint alone is not proof of resolution.RequestInterface, StreamInterface).InflateStream and AppendStream (direct and transitive) and record which code paths depend on them. This scopes the 3.2.0 relevance in under an hour.LimitStream for chunking).composer update guzzlehttp/psr7 --with-dependencies, then re-run the stream/integration test suite. This is a dependency bump, not a refactor — low effort, removes a known silent-corruption path.fopen + stream_get_contents) with Utils::streamFor().CachingStream for retryable requests, LimitStream for large transfers)."require": {
"guzzlehttp/psr7": "^3.2",
"php": "^8.1"
}
composer update guzzlehttp/psr7 --with-dependencies and confirm the resolved version in composer.lock — the point of the floor is auditability.| Component | Compatibility Notes |
|---|---|
| Laravel 9/10 | ✅ Uses PSR-7; verify resolved version meets the 3.2.0 floor. |
| Guzzle v7.x | ✅ Bundles PSR-7; confirm the bundle resolves ≥ 3.2.0 or a patched 2.x. |
| Symfony HttpFoundation | ⚠️ May bundle a different PSR-7 impl. Use composer why to resolve. |
| Custom Middleware | ✅ Replace Symfony\Component\HttpFoundation streams with guzzlehttp/psr7 decorators. |
| File Uploads | ✅ MultipartStream/LimitStream for chunked uploads to S3/Cloud Storage. |
AppendStream users |
⚠️ Behavior change in 3.2.0: pre-timeout bytes are no longer discarded. Verify resume/retry paths. |
InflateStream users |
⚠️ Behavior change in 3.2.0: source read failures now surface. Verify error handling and retry-on-gzip paths. |
Utils::streamFor('data')) in tests/controllers.Query::parse/Query::build for URL query handling.AppendStream for concatenating files) — now safe to adopt, since the truncation defect is fixed.StreamDecoratorTrait for custom logic.Symfony streams with guzzlehttp/psr7 in legacy code — and audit those replacements for the same two defect patterns 3.2.0 just fixed upstream.FnStream) can obscure the call stack for errors.CachingStream buffers data in-memory/disk. Monitor memory_get_usage().composer.json + CI check on composer.lock) so individual services can't drift below it.read()/write() calls, short reads, source exceptions).LimitStream to cap memory usage for large payloads.MultipartStream with Laravel Filesystem").LimitStream + PumpStream enable memory-efficient processing of GB-sized files. Benchmark with 100MB+ payloads to validate CachingStream disk spillover.PumpStream to stream-process large files in queues. Note that the AppendStream fix matters most here — timeout-prone queue jobs are exactly where pre-timeout byte loss would have occurred.| Scenario | Impact | Mitigation Strategy |
|---|---|---|
Silent truncation via AppendStream (< 3.2.0) |
Bytes read before a timeout discarded; partial artifact stored or served as complete. | Upgrade to the 3.2.0 floor; add length/checksum assertions on concatenated streams. |
Swallowed decompression error via InflateStream (< 3.2.0) |
Decoded prefix returned while source failure is hidden; corrupt payload passes validation-by-shape. | Upgrade to the 3.2.0 floor; assert decoded byte length and checksum, not just "it parsed." |
| Stream Corruption | Partial data reads/writes. | Use hash() utility to validate stream integrity. |
Memory exhaustion (CachingStream) |
Worker OOM on large payloads. | Cap with LimitStream; prefer disk-backed temp streams; monitor memory_get_usage(). |
Debug opacity (FnStream, nested decorators) |
Slow incident triage. | Log decorator entry/exit; avoid stacking decorators without a named wrapper. |
TPM recommendation: Treat 3.2.0 as a required patch, not an optional upgrade. It is a small, low-risk change that closes a silent data-integrity gap in two decorators this assessment already recommends. Sequence it as an immediate dependency-floor bump across services, follow with integrity assertions in stream tests, and only then proceed with the broader decorator adoption plan.
How can I help you explore Laravel packages today?