mariuslundgard/php-server
Composer 安装命令:
composer require mariuslundgard/php-server
包简介
A minimal routable HTTP middleware framework for PHP.
README 文档
README
Features
- Routable middleware (application layers)
- Routable controller actions
Examples
This is the canonical Hello World example:
<?php require 'vendor/autoload.php'; $app = (new Server\Module()) ->map([ 'fn' => function ($req, $res) { $res->write('<h1>Hello, world</h1>'); } ]) ->call() // calls the application ->send(); // outputs the headers and response body
This example shows how to use middleware and map controllers:
<?php require 'vendor/autoload.php'; class HeaderFilter extends Server\Layer { public function call(Server\Request $req = null, Server\Error $err = null) { $res = parent::call($req, $err); $res->body = '<h1>'.$res->body.'</h1>'; return $res; } } class FrontController extends Server\Controller { public function index() { return 'Hello, world!'; } } $app = new Server\Module(); $app->employ([ 'class' => 'HeaderFilter', ]); $app->map([ 'controller' => 'FrontController', ]); $app->call()->send(); // outputs: <h1>Hello, world!</h1>
统计信息
- 总下载量: 36
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-08-09