ap-lib/routing-builder
Composer 安装命令:
composer require ap-lib/routing-builder
包简介
README 文档
README
A helper repository for managing routing indexes: https://github.com/ap-lib/routing This package allows you to define routes using attributes directly in your handlers, making the development process easier.
Installation
composer require ap-lib/routing-builder
Features
- Help to define routing index using attributes
- Group routes easily with RouteGroup
Requirements
- PHP 8.3 or higher
Getting started
Base controller
class Main { #[Route(path: "/")] public static function root(): string { return "hello world"; } }
Group routes
#[RouteGroup(path: "/users")] class Users { #[Route(path: "")] public static function list(): array { return []; } #[Route(path: "/create", method: Method::POST)] public static function create(): Json { return new Json( ["id" => 123456], 201 ); } #[Route(path: "/update", method: Method::PUT)] public static function update(): Response { return new Response(code: 204); } #[Route(path: "/delete", method: Method::DELETE)] public static function delete(): Response { return new Response(code: 204); } }
Preparing an Index for All Classes in a Directory
For more details on routing and indexes, see: https://github.com/ap-lib/routing
$index = new HashmapIndex(); $builder = new ByAttributes(__DIR__ . "/Handlers"); $builder->modifyIndex($index);
统计信息
- 总下载量: 29
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-02-07