System Requirements

  • Web server with URL rewriting
  • PHP 7.4 or newer

Step 1: Install Composer

Don’t have Composer? It’s easy to install by following the instructions on their download page.

Step 2: Install Slim

We recommend you install Slim with Composer. Navigate into your project’s root directory and execute the bash command shown below. This command downloads the Slim Framework and its third-party dependencies into your project’s vendor/ directory.

composer require slim/slim:"4.*"

Step 3: Install a PSR-7 Implementation and 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. 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:

Slim PSR-7

composer require slim/psr7

Nyholm PSR-7 and Nyholm PSR-7 Server

composer require nyholm/psr7 nyholm/psr7-server

Guzzle PSR-7

For usage with Guzzle PSR-7 version 2:

composer require guzzlehttp/psr7 "^2"

For usage with Guzzle PSR-7 version 1:

composer require guzzlehttp/psr7 "^1"
composer require sapphirecat/slim4-http-interop-adapter

Laminas Diactoros

composer require laminas/laminas-diactoros

Step 4: Hello World

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';

$app = AppFactory::create();

$app->get('/', function (Request $request, Response $response, $args) {
    $response->getBody()->write("Hello world!");
    return $response;