guzzlehttp/psr7

A full PSR-7 HTTP message implementation with stream decorators, URI helpers, and query-string parsing.

Library
Composer
v3.0.0
7,935stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
84/100Excellent
Development Activity92
Maintenance84
Community60
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
75/100Good
Architecture84
Code Quality85
Innovation62
Learning Curve68

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, and UploadedFile implementations of PSR-7
  • An HttpFactory implementing PSR-17 for creating requests, responses, streams, and URIs
  • A Uri class 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 MultipartStream and AppendStream without 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.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search