felipecwb/routing
Composer 安装命令:
composer require felipecwb/routing
包简介
More One Simple Router for PHP.
README 文档
README
More one simple Routing library for PHP.
You'll need know about Regex Patterns.
Instalation
{
"felipecwb/routing": "dev-master"
}
Example:
<?php use Felipecwb\Routing\Router; // Exceptions use Felipecwb\Routing\Exception\ResolverException; use Felipecwb\Routing\Exception\RouteNotFoundException; $router = Router::create(); $router->add('/', function () { echo "Hello World!"; }); $router->add('/hello/(\w+)', function ($name) { echo "Hello {$name}!"; }); $router->add('/article/(\d+)', function ($id, $extraStr) { echo "Article {$id}! ${extraStr}"; }); try { $router->dispatch('/'); // with arguments $router->dispatch('/hello/felipecwb'); // with extra arguments $router->dispatch('/hello/10', ['Extra String!']); } catch (RouteNotFoundException $e) { echo "Sorry! The target can not be found!"; } catch (ResolverException $e) { echo "Sorry! The target can not be executed!"; } die;
Look in tests for more explanation
Contributions
Feel free to contribute.
- Create a issue.
- Follow the PSR-2 and PSR-4
- PHPUnit to tests
License MIT
统计信息
- 总下载量: 45
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-10-18