Slim PSR-7

Strict, standards-compliant PSR-7 HTTP message implementation built for the Slim framework.

Library
Composer
v1.8.0
153stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
45/100Fair
Development Activity0
Maintenance20
Community80
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
73/100Good
Architecture76
Code Quality84
Innovation60
Learning Curve72

slim/psr7 is a concrete, strict implementation of PSR-7 (HTTP Message Interface) and PSR-17 (HTTP Factory Interface), providing the Request, Response, Stream, Uri, Headers, and UploadedFile classes any PSR-7-compatible PHP application needs to represent HTTP messages as immutable value objects. It was built as the default message implementation for Slim 4, but because it only depends on the PSR interfaces (not Slim itself), it’s usable standalone in any PHP project or middleware stack that speaks PSR-7/PSR-17.

It registers itself as a provider for psr/http-message-implementation and psr/http-factory-implementation in Composer’s metadata, letting dependency-injection containers and frameworks that request “any PSR-7 implementation” resolve to it automatically.

What You Get

  • Immutable Request/Response/ServerRequest classes implementing PSR-7 exactly
  • Stream, NonBufferedBody for reading/writing HTTP body content, including streamed responses
  • Uri, Headers, Cookies, Environment, and UploadedFile value objects
  • PSR-17 Factory classes for constructing requests, responses, streams, and URIs
  • Registered psr/http-message-implementation and psr/http-factory-implementation Composer providers so DI containers auto-resolve it

Common Use Cases

  • Providing the default HTTP message implementation for a Slim 4 application
  • Satisfying a PSR-7/PSR-17 dependency in any framework or middleware that is implementation-agnostic
  • Writing PSR-15 middleware that needs a concrete Request/Response implementation to test against
  • Building lightweight PHP microservices or APIs without adopting a full framework

Under The Hood

Architecture: The library is a flat set of value-object classes under src/ (Request.php, Response.php, Message.php, Stream.php, Uri.php, Headers.php, Cookies.php, Environment.php, UploadedFile.php, NonBufferedBody.php) plus a src/Factory directory for PSR-17 construction helpers and src/Interfaces for a couple of Slim-specific extension points (e.g. non-buffered body streaming) layered on top of the PSR contracts. Tech Stack: Pure PHP 8.0+, depending only on psr/http-message, psr/http-factory, fig/http-message-util (status code/method constants), and ralouphie/getallheaders (a small polyfill for reading headers on non-Apache SAPIs) — no framework dependency at all. Code Quality: ~3,300 lines across a dozen focused classes, tested with PHPUnit plus the shared http-interop/http-factory-tests and php-http/psr7-integration-tests suites (ensuring spec-compliance against community-standard PSR-7 conformance tests, not just its own tests), statically analyzed with PHPStan, and style-checked with PHP_CodeSniffer — a notably rigorous QA setup for a message implementation. API Design: Every mutator method returns a new immutable instance per the PSR-7 spec (withHeader(), withBody(), etc.), so the API surface is exactly what any PHP developer who has used PSR-7 before already expects, minimizing surprises when swapping in from another implementation like Guzzle’s or Laminas’s.

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