Skip to main content
Slim
a micro framework for PHP

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

⚡ Fast & Lightweight
🎯 PSR-7 Compatible
🔧 Easy to Use
Hello World Example
<?php
use PsrHttpMessageResponseInterface as Response;
use PsrHttpMessageServerRequestInterface as Request;
use SlimFactoryAppFactory;

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

$app = AppFactory::create();

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

$app->run();

Download & Install

📦

Get Started with Composer

We recommend installing the Slim Framework with the Composer dependency manager.

1

Create a new project

The easiest way to start working with Slim is to create a project using Slim-Skeleton as a base:

$ composer create-project slim/slim-skeleton [my-app-name]

Replace [my-app-name] with the desired directory name for your new application.

2

Run your application

You can then run it with PHP's built-in webserver:

$ cd [my-app-name]; php -S localhost:8080 -t public

Features

🚀

HTTP Router

Slim provides a fast and powerful router that maps route callbacks to specific HTTP request methods and URIs. It supports parameters and pattern matching.

🔧

Middleware

Build your application with concentric middleware to tweak the HTTP request and response objects around your Slim app.

📋

PSR-7 Support

Slim supports any PSR-7 HTTP message implementation so you may inspect and manipulate HTTP message method, status, URI, headers, cookies, and body.

Dependency Injection

Slim supports dependency injection so you have complete control of your external tools. Use any PSR-11 ContainerInterface implementation.

Community

You can chat with other Slim Framework developers to share code or troubleshoot tricky issues using either Slack or Discourse.

💡

Discourse forum

We also have a Discourse forum at discourse.slimframework.com/ for when you have a more in depth question.