定制 tgrj/tweb_dispatch 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

tgrj/tweb_dispatch

最新稳定版本:v1.0.2

Composer 安装命令:

composer require tgrj/tweb_dispatch

包简介

minimalistic router

README 文档

README

minimalistic router

Background

I used noodlehaus/dispatch for routing, but wanted the feature to have routes be declarable as static class method attributes instead for convenience. Thus I forked the original code and extended all with some kind of "reflection layer".

Usage

Basically with this it should be possible to define routes as attributes on static class methods, as if if were the original route() method (method, uri path and middleware, while the final function would be the static method itself on which the attribute is attached).

Example:

class IndexController {
	#[Route('GET', '/')]
	public static function index(): callable
	{
		return response('index page');
	}

	#[Route('GET', '/item/:id', ['Middleware::auth'])]
	public static function index(array $params): callable
	{
		return response('item-id: ' . ($params['id'] ?? 'fail'));
	}
}

In the bootstrap (in my case it's the entry index.php file) you have to register the classes, which hold the attributes and finally use the dispatch() method as if it just were noodlehaus/dispatch:

tweb_add_routes_controllers(IndexController::class, ...);
dispatch();

Licence

noodlehaus/dispatch is under MIT licence, so is this repo as well!

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 9
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固