Slim 4.5.0 released
We are excited to announce the Slim 4.5.0 release. Please direct all your feedback for this release to the Slim 4 Release Feedback Thread. The new docs are located here.
Slim 是一个PHP微型框架,它可以帮助你快速开发简单且强大的web应用和API。
<?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('/hello/{name}', function (Request $request, Response $response, array $args) {
$name = $args['name'];
$response->getBody()->write("Hello, $name");
return $response;
});
$app->run();
我们推荐你使用 Composer 依赖管理来安装slim框架。
只安装slim核心代码,demo地址:slim4you
$ mkdir -p slim-demo/public && cd slim-demo
$ composer require slim/slim:"4.*" slim/psr7
$ touch public/index.php //复制页面最上面的demo代码
$ php -S localhost:8080 -t public public/index.php
开始使用slim最简单的方法是用 Slim-Skeleton创建工程项目,只需要执行如下命令:
$ php composer.phar create-project slim/slim-skeleton:dev-master [my-app-name]
用你的项目名称替换 [my-app-name]
这里。
你可以使用PHP内置web服务器运行项目:
$ cd [my-app-name]; php -S localhost:8080 -t public public/index.php
Slim provides a fast and powerful router that maps route callbacks to specific HTTP request methods and URIs. It supports parameters and pattern matching.
Build your application with concentric middleware to tweak the HTTP request and response objects around your Slim app.
Slim supports any PSR-7 HTTP message implementation so you may inspect and manipulate HTTP message method, status, URI, headers, cookies, and body.
Slim supports dependency injection so you have complete control of your external tools. Use any Container-Interop container.
We are excited to announce the Slim 4.5.0 release. Please direct all your feedback for this release to the Slim 4 Release Feedback Thread. The new docs are located here.
We are excited to announce the Slim 4.4.0 release. Please direct all your feedback for this release to the Slim 4 Release Feedback Thread. The new docs are located here.
We are excited to announce the Slim 3.12.3 release.
akrabat
, silentworks
and codeguy
if you have have
questions
or need assistance.
We can be found on Slack at slimphp.slack.com.