Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

Slim

> 编程语言
Open source

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

12.3K stars0 likes5 views
WebsiteGitHub

About

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

Slim Framework

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

Installation

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

bash
composer require slim/slim

This will install Slim and all required dependencies. Slim requires PHP 7.4 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-Psr7 - This is the Slim Framework PSR-7 implementation
  • httpsoft/http-message & httpsoft/http-server-request - This is the fastest, strictest and most lightweight implementation available
  • Nyholm/psr7 & Nyholm/psr7-server - Performance is almost the same as the HttpSoft implementation
  • Guzzle/psr7 - This is the implementation used by the Guzzle Client, featuring extra functionality for stream and file handling
  • laminas-diactoros - This is the Laminas (Zend) PSR-7 implementation

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:

bash
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:

php
<?php

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

AppFactory::setSlimHttpDecoratorsAutomaticDetection(false);
ServerRequestCreatorFactory::setSlimHttpDecoratorsAutomaticDetection(false);

$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:

  • Slim-Psr7 - Install using composer require slim/psr7
  • httpsoft/http-message & httpsoft/http-server-request - Install using: composer require httpsoft/http-message httpsoft/http-server-request
  • Nyholm/psr7 & Nyholm/psr7-server - Install using composer require nyholm/psr7 nyholm/psr7-server
  • Guzzle/psr7 - Install using composer require guzzlehttp/psr7
  • laminas-diactoros - Install using composer require laminas/laminas-diactoros

Then create file public/index.php.

…

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

bash
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.

Tests

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

bash
git clone https://github.com/slimphp/Slim
composer install
composer test

Contributing

Please see CONTRIBUTING for details.

Learn More

Learn more at these links:

  • Website
  • Documentation
  • Slack
  • Support Forum
  • Twitter
  • Resources

Security

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

For enterprise

Available as part of the Tidelift Subscription.

The maintainers of Slim and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.

Contributors

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

Individuals

Organizations

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

License

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

Issues· 15 open

View all issuesOpen on GitHub
  • #3427

    More info on v5 changes

    Updated Sep 23, 2026
  • #3374

    Routing does not match (slash %2F in path parameter)

    Slim 5Updated Mar 26, 2026
  • #3431

    Description

    Updated Mar 24, 2026
  • #3073

    Unify CallableResolver and AdvancedCallableResolver

    Slim 5Updated May 23, 2025
  • #3338

    Documentation for integration tests with Slim handlers/controllers

    Slim 5Updated Jan 29, 2025
  • #3280

    Slim 5: Ensure that route attributes are always in the Request

    Slim 5Updated Oct 19, 2024
  • #3287

    Error handling still problematic

    help wantedSlim 5Updated Jul 20, 2024
  • #3323

    Unbuffered streaming output

    Updated May 21, 2024
  • #2943

    Logger not forwarded to own ErrorHandlingMiddleware

    bugSlim 5Updated Aug 3, 2022
  • #3071

    Resolving middleware breaks if resolver throws unexpected exception type

    Slim 4Slim 5Updated Apr 26, 2021

> Tags

PHPframeworkmicro-frameworkphpphp-micro-framework

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 28, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言