viloveul/router
Composer 安装命令:
composer require viloveul/router
包简介
Http Router for handling request path
README 文档
README
Installation
make sure your php version > 7.0
composer require viloveul/router
HOW
require __DIR__ . '/vendor/autoload.php'; // init collection object $collection = new Viloveul\Router\Collection(); // declare class controller for handler class MyController { public function look($name) { return $name; } } // declare hello handler from my controller $helloRoute = new Viloveul\Router\Route('GET /hello/:name', [MyController::class, 'look']); // or // $helloRoute = new Viloveul\Router\Route('GET /hello/:name', [MyController::class, 'look']); // add foo to collection $collection->add($helloRoute); // declare foo handler $fooRoute = new Viloveul\Router\Route('GET /foo/{:bar}', function($bar) { return $bar; }); // add foo to collection $collection->add($fooRoute); // declare test handler $testRoute = new Viloveul\Router\Route('/test/:name', [ 'method' => 'GET|POST|PUT|PATCH', 'handler' => function ($name) { return $name; } ]); // add test to collection $collection->add($testRoute); // init object dispatcher with collection $router = new Viloveul\Router\Dispatcher($collection); // in action $router->dispatch('GET', Zend\Diactoros\UriFactory::createUri('/hello/zafex')); $route1 = $router->routed(); $router->dispatch('GET', Zend\Diactoros\UriFactory::createUri('/foo/hello-world')); $route2 = $router->routed(); $router->dispatch('GET', Zend\Diactoros\UriFactory::createUri('/test/fajrul-akbar-zuhdi')); $route3 = $router->routed(); var_dump($route1, $route2, $route3);
viloveul/router 适用场景与选型建议
viloveul/router 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 184 次下载、GitHub Stars 达 1, 最近一次更新时间为 2018 年 12 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「library」 「router」 「component」 「zafex」 「viloveul」 「fajrulaz」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 viloveul/router 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 viloveul/router 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 viloveul/router 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
FSi DataSource Component
Inbox pattern process implementation for your Laravel Applications
Priveate for SkeekS CMS
Router
PMVC App Action Router
Database alias router extension for Nette Framework
统计信息
- 总下载量: 184
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-12-29