Slim PSR-7
Strict, standards-compliant PSR-7 HTTP message implementation built for the Slim framework.
Repository Health
Technical Analysis
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/ServerRequestclasses implementing PSR-7 exactly Stream,NonBufferedBodyfor reading/writing HTTP body content, including streamed responsesUri,Headers,Cookies,Environment, andUploadedFilevalue objects- PSR-17
Factoryclasses for constructing requests, responses, streams, and URIs - Registered
psr/http-message-implementationandpsr/http-factory-implementationComposer 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.
Used by 2 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.
Typemill
CMS
Open-source flat-file CMS for publishing Markdown-based documentation, manuals, and eBooks without a database.