kiryi/routyi
Composer 安装命令:
composer require kiryi/routyi
包简介
Routing mechanism for web applications.
README 文档
README
A routing mechanism for web applications.
Installation
composer require kiryi/routyi
Usage
First set up the routing table. Then use:
$routyi = new \Kiryi\Routyi\Router()); $routyi->route();
All endpoint classes have to implement the Kiryi\Routyi\EndpointInterface and so must have a method run(array $params).
Constructor Definition
__construct(?string $namespace = null, ?string $routingTableFilepath = null, ?string $configFilepath = null)
Parameters
namespace
Optional namespace your routing table endpoints start with. If no namespace is provided, endpoints have to be configured with their fully qualified namespace in routing table.
routingTableFilepath
Optional filepath to the routing table INI file. It is relative to your project's root directory. If no filepath is provided, default (config/routing.ini) is used (more information).
configFilepath
Optional filepath to a configuration INI file. It is relative to your project's root directory. If no filepath is provided, default (config/routyi.ini) is used. This filepath is only relevant if you are using a subdirectory (more information).
Method Definition route
route(): void
The Routing Table
The routing table is an INI file consisting of routes (key) and corresponding endpoints (value). The default filepath is config/routing.ini. If you want to change this, see constructor parameter string $rountingTableFilepath.
Basic Structure
/ = Fully\Qualified\Namespace\DefaultController /foo = Fully\Qualified\Namespace\FooController /foo/bar = Fully\Qualified\Namespace\BarController
The single slash '/' is the default controller. It is used as home page and everytime no actual route is found.
If you want to configure a namespace for the endpoints, see constructor parameter string $namespace and the provided example.
Routes Parameters
The URL will be processed from the longest possible route to the shortest. As soon as a route from the routing table matches, everything after the route part is considered parameters and gets put into an array, which is passed to the run method.
Using a Subdirectory
If you are using a subdirectory for your web application, you have to specify a configuration INI file with the following content:
[routyi] subDir = {YOURSUBDIRECTORY}
The default filepath is config/routyi.ini. If you want to change this, see constructor parameter string $configFilepath.
Example
configuration/routes.ini
/ = HomeController
/about = AboutController
src/Bootstrap.php
(new \Kiryi\Routyi\Router('MyProject\\Controller\\', 'configuration/routes.ini'))->route();
URL mydomain.com will route to MyProject\Controller\HomeController.
URL mydomain.com/about will route to MyProject\Controller\AboutController.
URL mydomain.com/wrong/route will route to MyProject\Controller\HomeController. Since /wrong/route is not a matching route, the part is interpreted as parameters and passed to the run method of the HomeController.
kiryi/routyi 适用场景与选型建议
kiryi/routyi 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 41 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 04 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 kiryi/routyi 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kiryi/routyi 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 41
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2020-04-04