strident/router
最新稳定版本:2.0.1
Composer 安装命令:
composer require strident/router
包简介
Routing component designed for ease of use and speed. Built for Trident.
关键字:
README 文档
README
Routing component designed for ease of use and speed. Built for Trident.
##Installation
Installation is available via Composer. Add the package to your composer.json:
$ composer require strident/router ~2.0
##Usage
The Strident Router package is flexible and allows you to swap out components to extend it easier. To create a Router, do the following:
use Strident\Router\RouteFactory; use Strident\Router\RouteMatcher; use Strident\Router\Router; $factory = new RouteFactory(); $matcher = new RouteMatcher(); $router = new Router($factory, $matcher);
From there, you can define routes like so:
$router->route("route_name", "/route/path/{parameter}/{placeholders}") ->target("GET", "FooController::getAction") ->target("POST", "FooController::postAction") ;
The route() method of the Router returns the instance of a the created Route. The Route can then define it's targets for specific HTTP methods by using the target() method.
To dispatch the current request in the Router, use the dispatch() method of the Router.
$matched = $router->dispatch("GET", "/route/path/1/2");
The return value of dispatch() is an array containing information about the matched route. This includes the name of the route, the request method, the path, and the parameters (by name, and index).
统计信息
- 总下载量: 15
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-02-10