
Slim
A small PHP framework for building web apps and APIs with routing and PSR-7 support.
- Stars
- 12.3k
- Forks
- 2k
- Licence
- MIT
- Language
- PHP
- Last update
- 5 days ago
- Type
- Framework
What it is
Slim is a PHP micro-framework for writing web applications and APIs. You define routes that map web addresses to PHP functions, and Slim handles the request and response flow around them. It is designed to stay small, so you add only the parts you need.
- Create a simple web page or endpoint with a route such as /hello/{name}
- Build a JSON API by returning responses from route handlers
- Add error handling middleware with addErrorMiddleware
- Use the built-in PHP development server to test an app locally
Great for
- PHP developers who want a lightweight alternative to a full-stack framework
- Building small JSON or HTTP APIs with a few routes
- Projects that want to choose their own PSR-7 HTTP message implementation
- Learning how HTTP routing and middleware work in PHP
Not ideal for
- Teams wanting a full framework with built-in ORM, admin panels, and batteries included, because Slim leaves many of those choices to you
- Projects that must run on PHP versions older than 7.4, since the README states PHP 7.4 or newer is required
- Non-PHP developers, since the project is entirely PHP-based
How to get it
- 1
Install with a package manager
You'll need: PHP 7.4 or newer · Composer
Install Slim with Composer
composer require slim/slim - 2
Run it
- Install a PSR-7 implementation such as composer require slim/psr7
- Create public/index.php and add the Hello World routes from the README
- Run php -S localhost:8000 -t public from the project folder
- Open http://localhost:8000/hello/world in your browser
- 3
Get the most out of it
- Install Slim-Http decorators with composer require slim/http for extra request and response helpers
- Choose a PSR-7 implementation that fits your performance or stream-handling needs, as the README compares several
- Read the official documentation at slimframework.com for web server configuration
- Run the test suite with composer test after cloning to explore the code
Downloads
Strengths
- Small and focused, as described as a micro-framework
- Built on PSR-7, PSR-15, and PSR-3 standards per its topics and README
- Installs with a single Composer command and works with several PSR-7 libraries
Trade-offs
- Minimal by design, so you must pick and wire together libraries for things like databases and templating
- The README points to external documentation for web server setup rather than covering it in depth
- Choosing a PSR-7 implementation adds an early decision the beginner must understand
How it compares
| Project | Stars | Type | Level | Updated | Best for |
|---|---|---|---|---|---|
| Slim (this) | 12.3k | Framework | intermediate | 5 days ago | PHP developers who want a lightweight alternative to a full-stack framework |
| symfony | 31.2k | Library | intermediate | 4 days ago | PHP developers building web applications that need a structured framework |
| framework | 35k | Framework | intermediate | 4 days ago | PHP developers building web applications or APIs |
| guzzle | 23.4k | Library | intermediate | 11 days ago | PHP developers who need to call external REST or web service APIs |
| monolog | 21.4k | Library | intermediate | 5 days ago | PHP developers who need structured logs from an application |
| pest | 11.8k | Library | intermediate | 4 days ago | PHP developers who want to add automated tests to a project |
Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.