liamato / ligght
简单的PHP路由器
1.0.1
2015-01-10 01:26 UTC
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2024-09-28 16:56:59 UTC
README
#ligght ###简单的PHP路由器
ligght是一个PHP微型路由器,可以帮助您轻松地路由HTTP请求。ligght是创建API的最简单和最快的方式。
##特性
- 标准HTTP方法
- GET
- POST
- PUT
- DELETE
- PATCH
- OPTIONS
- HEAD
- DEBUG
- 使用
\ligght\Interfaces\HttpMethod接口自定义HTTP方法 - 参数路由
##入门
###要求
- PHP >= 5.3.*
- Apache
mod_rewrite
###配置环境
您必须在.htaccess文件中包含此代码片段
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php?$0 [PT,L]
或者将此 .htaccess文件复制到与index.php相同的文件夹中
###Hello World教程
设置路由如下
\ligght\Router::getInstance()->route( \ligght\Router::GET, '/hello/:name', function($name){ print "Hello, $name"; }, array(':name') );
然后运行路由器
\ligght\Router::getInstance()->run();
####风格指南
完全使用PSR-2编码风格编写