neverender / sneeze
一个简单的php 5.4+ 路由器
dev-master
2015-03-01 05:30 UTC
Requires
- php: >=5.4.0
This package is not auto-updated.
Last update: 2024-09-24 06:31:39 UTC
README
##Sneeze##
Sneeze 是一个简单的php路由器。
####要求#### php >= 5.4.0
####安装####
使用 Composer
####示例####
实例化 Sneeze 应用程序
$app = new \Sneeze\Sneeze;
定义一个 HTTP GET 路由
$app->get('/hello/:name', function($name) {
echo "hello $name";
});
运行它
$app->run();
####更多####
您还可以定义 PUT、POST 和 DELETE HTTP 路由。由于现代浏览器不支持 PUT 和 DELETE,您可以通过发送一个带有 "_METHOD" 参数的 POST 请求来模拟它们
<form action="/put/route/1" method="post">
<input type="hidden" name="_METHOD" value="PUT"/>
<!-- other stuff -->
</form>
在路由内部,您可以访问 $this->request,它是一个包含常用请求变量(包括 'get'、'post'、'uri'、'method'、'body' 等)的关联数组。
####待办事项####
- 测试
- 重构以使其更易于测试