lorenzo-d-alipio/basicrouter
Composer 安装命令:
composer require lorenzo-d-alipio/basicrouter
包简介
Simple router forked from simonham with simple modifications
README 文档
README
This router is based on simonhamp/routes of which I forked months ago. There is nothing wrong about the original router. However, I decided to add another method to extract the controller and the controller method from the route() shown in the original class.
Installation
This can be installed using composer.{"require":{ "basicrouter": "dev-master" }, "repositories": [{ "type": "vcs", "url": "https://github.com/Bryan-D-Lee/basicrouter"
} ]
}
If you install it via composer, make sure to add namespace on top of the Router class.
<?php namespace System\Libraries;
Example of composer installed
<?php
require_once(DIR .'/vendor/autoload.php');
$routes = array(
'controller/(:any)/(:any)/(:any)' => 'test/index/$1/$2/$3/',
'register/' => 'MyController/myController_action'
);
$url = 'dir/controller/method/param_one/param_two/param_threee';
$default_dir = ('dir/');
$request = trim(str_replace($default_dir, '', $url));
System\Libraries\Router::add($routes);
$action_request = System\Libraries\Router::route($request);
print_r(array_filter($action_request));
Alternative installation example
<?php
include('Router.php');
$routes = array(
'controller/(:any)/(:any)/(:any)' => 'test/index/$1/$2/$3/',
'register/' => 'MyController/myController_action'
);
$url = 'dir/controller/method/param_one/param_two/param_threee';
$default_dir = ('dir/');
$request = trim(str_replace($default_dir, '', $url));
Router::add($routes);
$action_request = Router::route($request);
print_r(array_filter($action_request));
The above examples should return something like this
Array ( [0] => test [1] => index [2] => method [3] => param_one [4] => param_two [5] => param_threee )
By writing a simple dispatcher, we can easily dispatch the controller/action + parameters (coming up soon).统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-05-04