Slim Framework

A lightweight PHP micro framework for building fast web applications and APIs

Framework
Composer
v4.15.2
12,282stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
78/100Good
Development Activity64
Maintenance56
Community92
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
77/100Good
Architecture82
Code Quality80
Innovation70
Learning Curve75

Slim is a PHP micro-framework built around PSR-7 HTTP messages, PSR-15 middleware, and a fast router, giving developers just enough structure to build web applications and REST APIs without the overhead of a full-stack framework. The core App class wires together routing, middleware dispatch, error handling, and response emission, while every major piece — the PSR-7 implementation, dependency container, and error renderers — is swappable via Slim’s factory and interface layer.

Because Slim deliberately ships without an opinionated PSR-7 implementation or container, teams choose their own (Slim-Psr7, PHP-DI, Nyholm, etc.), which keeps the framework’s own footprint small while still supporting production-grade dependency injection and request/response handling. This composability, combined with over a decade of maintenance, has made Slim one of the most widely used micro frameworks in the PHP ecosystem.

What You Get

  • A fast router with route groups, named routes, and route parameter constraints
  • PSR-15 middleware dispatch via MiddlewareDispatcher, composable in application or route scope
  • Pluggable PSR-7 implementation and PSR-11 container support through Slim’s Factory layer
  • Built-in error handling with customizable renderers (Handlers, Error namespaces)
  • A ResponseEmitter that correctly streams PSR-7 responses back to the client

Common Use Cases

  • Building lightweight REST APIs without the overhead of a full-stack framework like Laravel or Symfony
  • Adding a thin HTTP routing layer in front of an existing domain/service layer in a modular monolith
  • Prototyping web applications quickly while retaining PSR-7/PSR-15 standards compliance for future growth
  • Embedding a minimal, dependency-injectable web front controller inside a larger PHP application

Under The Hood

Architecture - Slim’s Slim/App.php (226 lines) is the composition root: it builds a RouteCollector/router, a MiddlewareDispatcher, and error Handlers, then dispatches incoming PSR-7 requests through middleware to matched route callables and emits the resulting response via ResponseEmitter.php; the Slim/Routing, Slim/Middleware, Slim/Handlers, Slim/Error, and Slim/Factory namespaces each own one concern, keeping the framework’s own footprint intentionally small (72 source files). Tech Stack - modern PHP (7.4+) built on PSR-7 (HTTP messages), PSR-15 (middleware), and PSR-11 (container) interfaces rather than bundling a fixed implementation of any of them, with Composer as the packaging mechanism and phpstan/psalm configs for static analysis. Code Quality - a 53-file PHPUnit test suite (roughly matching the 72 source files in scope) covers routing, middleware dispatch, and error handling, and the repo enforces phpcs, phpstan, and psalm in CI, indicating disciplined static-analysis and style gates on top of tests. API Design - the framework favors a minimal, fluent surface ($app->get()/post()/group()/add()) that mirrors other popular micro-frameworks, so PHP developers can get a route responding in a handful of lines, though the requirement to separately choose and wire a PSR-7 implementation adds one extra setup step compared to fully batteries-included frameworks.

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