Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs

framework, api, micro, router, micro-framework, php, php-micro-framework, psr-15, psr-3, psr-7, slim, slim-framework


Slim Framework

Build Status Coverage Status Total Downloads License

Slim is a PHP micro-framework that helps you quickly write simple yet powerful web applications and APIs.


It's recommended that you use Composer to install Slim.

$ composer require slim/slim:^4.0

This will install Slim and all required dependencies. Slim requires PHP 7.1 or newer.

Choose a PSR-7 Implementation & ServerRequest Creator

Before you can get up and running with Slim you will need to choose a PSR-7 implementation that best fits your application. A few notable ones:

Slim-Http Decorators

Slim-Http is a set of decorators for any PSR-7 implementation that we recommend is used with Slim Framework. To install the Slim-Http library simply run the following command:

composer require slim/http

The ServerRequest and Response object decorators are automatically detected and applied by the internal factories. If you have installed Slim-Http and wish to turn off automatic object decoration then you can use the following statements:


use Slim\Factory\AppFactory;
use Slim\Factory\ServerRequestCreatorFactory;


$app = AppFactory::create();

// ...

Hello World using AppFactory with PSR-7 auto-detection

In order for auto-detection to work and enable you to use AppFactory::create() and App::run() without having to manually create a ServerRequest you need to install one of the following implementations:

Then create file public/index.php.

use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;

require __DIR__ . '/../vendor/autoload.php';

// Instantiate App
$app = AppFactory::create();

// Add error middleware
$app->addErrorMiddleware(true, true, true);

// Add routes
$app->get('/', function (Request $request, Response $response) {
    $response->getBody()->write('<a href="/hello/world">Try /hello/world</a>');
    return $response;

$app->get('/hello/{name}', function (Request $request, Response $response, $args) {
    $name = $args['name'];
    $response->getBody()->write("Hello, $name");
    return $response;


You may quickly test this using the built-in PHP server:

$ php -S localhost:8000 -t public

Going to http://localhost:8000/hello/world will now display "Hello, world".

For more information on how to configure your web server, see the Documentation.


To execute the test suite, you'll need to install all development dependencies.

$ git clone
$ composer install
$ composer test


Please see CONTRIBUTING for details.

Learn More

Learn more at these links:


If you discover security related issues, please email instead of using the issue tracker.

Professional support

Slim is part of Tidelift which gives software development teams a single source for purchasing and maintaining their software, with professional grade assurances from the experts who know it best, while seamlessly integrating with existing tools.


Code Contributors

This project exists thanks to all the people who contribute. Contribute.

Financial Contributors

Become a financial contributor and help us sustain our community. Contribute



Support this project with your organization. Your logo will show up here with a link to your website. Contribute


The Slim Framework is licensed under the MIT license. See License File for more information.