guzzlehttp/psr7
A full PSR-7 HTTP message implementation with stream decorators, URI helpers, and query-string parsing.
Repository Health
Technical Analysis
guzzlehttp/psr7 is the reference PSR-7 (HTTP Message Interface) and PSR-17 (HTTP Factory) implementation used throughout the PHP ecosystem, providing concrete Request, Response, Uri, Stream, and UploadedFile classes plus a rich set of stream decorators (AppendStream, CachingStream, LimitStream, PumpStream, and more). It underlies Guzzle itself but is widely consumed standalone by any PHP project that needs standards-compliant HTTP message objects.
What You Get
- Full
Request,Response,ServerRequest, andUploadedFileimplementations of PSR-7 - An
HttpFactoryimplementing PSR-17 for creating requests, responses, streams, and URIs - A
Uriclass with RFC 3986-compliant parsing, resolution (UriResolver), comparison (UriComparator), and normalization - Stream decorators —
AppendStream,BufferStream,CachingStream,LimitStream,PumpStream,NoSeekStream,DroppingStream,LazyOpenStream,InflateStream— for composing and controlling stream behavior - Helper utilities (
Query,Header,MimeType,Utils) for query-string parsing, header manipulation, and mime-type lookup
Common Use Cases
- Building HTTP client or server middleware that needs concrete PSR-7 request/response objects, not just the interfaces
- Composing large file uploads or multipart bodies using
MultipartStreamandAppendStreamwithout loading everything into memory - Implementing PSR-15 middleware stacks or PSR-18 HTTP clients that require a PSR-17 factory implementation
- Manipulating and resolving URIs (relative-to-absolute resolution, query modification) in web crawlers or API clients
Under The Hood
Architecture: MessageTrait centralizes shared header/body/protocol-version logic reused by Request, Response, and ServerRequest; streams follow a decorator pattern via StreamDecoratorTrait, letting behaviors like caching, limiting, or lazy-opening wrap any base Stream transparently; Uri and its companion UriResolver/UriComparator/UriNormalizer classes implement RFC 3986 algorithms as static, stateless operations. Tech Stack: Pure PHP 7.2.5–8.5 with zero runtime dependencies beyond psr/http-message and psr/http-factory (the interfaces it implements), using PHPStan with a maintained baseline for static analysis and a Makefile-driven test/lint workflow. Code Quality: The tests/ tree mirrors src/ with dedicated unit tests per class, CI runs both a test suite and a separate static-analysis workflow, and the project maintains an UPGRADING.md documenting breaking changes across major versions — signs of disciplined, long-running maintenance (7,900+ stars, daily commit activity). API Design: PSR-7 immutability (withHeader(), withBody(), etc. return new instances) is fully honored, and the package additionally exposes convenience static factories (Utils::streamFor(), HttpFactory) that reduce the boilerplate PSR-7’s strict interfaces would otherwise require, making it noticeably more ergonomic than instantiating the raw interfaces yourself.
Used by 3 apps in this directory
EspoCRM
Marketing · Ecommerce · CRM
Open-source CRM platform with metadata-driven customization, field-level permissions, and a full REST API — deploy on your own infrastructure.
FreeScout
Customer Support
Run your own help desk and shared inbox — a fully self-hosted, open-source alternative to Zendesk and Help Scout with no per-agent fees.
wallabag
Bookmarks Archiving
Self-hosted read-it-later app that saves clean, ad-free articles from any webpage for distraction-free reading across all your devices.