strident/router 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

strident/router

最新稳定版本:2.0.1

Composer 安装命令:

composer require strident/router

包简介

Routing component designed for ease of use and speed. Built for Trident.

README 文档

README

#Router Build Status Coverage Code Climate

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

GitHub 信息

  • Stars: 1
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-02-10