nia / routing-facade-http
HTTP路由门面,用于简单地向给定的路由器添加HTTP路由。
此包的规范仓库似乎已消失,因此该包已被冻结。
1.1.0
2017-04-12 20:23 UTC
Requires
- php: >=7.0.0
- nia/requestresponse-http: *
- nia/routing: *
This package is not auto-updated.
Last update: 2022-03-09 07:21:45 UTC
README
HTTP路由门面,用于简单地向给定的路由器添加HTTP路由。
安装
使用Composer要求此包。
composer require nia/routing-facade-http
测试
运行单元测试,请使用以下命令
$ cd /path/to/nia/component/
$ phpunit --bootstrap=vendor/autoload.php tests/
如何使用
以下示例显示了如何使用HTTP路由门面组件处理常见用例。
$router = new Router(); // encapsulate the router into the facade. $facade = new HttpFacade($router); // simple rest handling. $facade->get('#^/articles/$#', $articleListHandler); $facade->put('#^/articles/$#', $articleUpdateHandler); $facade->post('#^/articles/$#', $articleCreateHandler); // routes with additional conditions and filters. $facade->get('#^/bookmarks/$#', $bookmarkListHandler, $myCondition, $myFilter); $facade->put('#^/bookmarks/$#', $bookmarkUpdateHandler, $myCondition, $myFilter); $facade->post('#^/bookmarks/$#', $bookmarkCreateHandler, $myCondition, $myFilter);