tea-aroma/route-architect
Composer 安装命令:
composer require tea-aroma/route-architect
包简介
Class-based route architecture for Laravel.
README 文档
README
A clean, class-based system for organizing Laravel routes.
Say goodbye to bloated web.php files. With
RouteArchitect, you define routes as classes — reusable, composable, and auto-discoverable. Perfect for apps with complex structures, admin panels, or modular APIs.
Why RouteArchitect?
- Keeps your
web.phpclean and maintainable. - Supports deeply nested and reusable route groups.
- Generates route names, views, prefixes, and URLs automatically.
- Easily extendable, testable, and auto-discoverable.
- Ideal for complex apps with admin panels, modules, or APIs.
Example:
class AdminRouteArchitect extends RouteArchitect { protected string $identifier = 'admin'; protected array $routeArchitects = [ DashboardRouteArchitect::class ]; } // Generates route name: admin.dashboard class DashboardRouteArchitect extends RouteArchitect { protected string $identifier = 'dashboard'; protected array | string | null $action = [ DashboardController::class, "index" ]; } // In another controller... return view(route_architect()->getSequenceEntry(DashboardRouteArchitect::class)->view);
Quick Start
Install the package:
composer require tea-aroma/route-architect
Generate your first RouteArchitect class:
php artisan make:route-architect AdminRouteArchitect --identifier=admin
This command will create a new class in app/RouteArchitects:
namespace App\RouteArchitects; use TeaAroma\RouteArchitect\Abstracts\RouteArchitect; /** * AdminRouteArchitect. */ class AdminRouteArchitect extends RouteArchitect { /** * The identifier. * * @var string */ protected string $identifier = 'admin'; }
Notice: By default, the identifier is derived from the class name if not specified.
Registering routes
- Automatically (default) — set
auto_scan = truein the config. - Manually — call
route_architect()->register()with yourRouteArchitectclass.
// web.php route_architect()->register(AdminRouteArchitect::class);
Configuration
You can publish the configuration file:
php artisan vendor:publish --provider="TeaAroma\RouteArchitect\Providers\RouteArchitectServiceProvider" --tag=config
Available options in config/route-architect.php:
| Option | Description |
|---|---|
namespace |
Base namespace for generated RouteArchitect classes. |
directory |
Base folder for generated RouteArchitect classes. |
auto_scan |
Automatically registers all RouteArchitect classes. |
url_variable_template |
Template for inserting route variables into URLs. |
url_delimiter |
Delimiter for URL segments. |
url_segment_delimiter |
Delimiter within individual URL segments. |
route_name_delimiter |
Delimiter for route name segments. |
view_name_delimiter |
Delimiter for view name segments. |
action_delimiter |
Delimiter between controller class and action method. |
sequences_group_name_mode |
Defines how the group name should be handled: only-base or every-group. |
Available properties
When you define your RouteArchitect class, you can configure it using the following properties:
| Property | Description |
|---|---|
identifier |
Acts as a base for name, view, url, prefix, and action if they are null. |
name |
Route name segment. |
view |
View name segment. |
prefix |
URL prefix to apply for this and nested routes. |
url |
URL segment. |
type |
HTTP method. |
action |
Controller action. |
controller |
Controller class to apply for this and nested routes. |
namespace |
Namespace to apply for this and nested routes. |
domain |
Domain constraint. |
customUrl |
Custom URL, bypasses automatic generation. |
middlewares |
Middleware classes to apply. |
excludeMiddlewares |
Middleware classes to exclude. |
routeArchitects |
Nested RouteArchitect classes. |
variables |
Route parameters for URL. |
autoScanRegisterMode |
Controls auto-registration behavior during scan. |
sequencesGroupName |
Sequences group name to apply for this and nested routes. |
registerMode |
Defines how the route should be registered. |
License
This package is open-sourced software licensed under the MIT license.
tea-aroma/route-architect 适用场景与选型建议
tea-aroma/route-architect 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 23 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 04 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「framework」 「routes」 「laravel」 「Architect」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 tea-aroma/route-architect 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tea-aroma/route-architect 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 tea-aroma/route-architect 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Framework HLEB2 is the foundation of the web application. Provides ease of development and application performance.
Generates a Blade directive exporting all of your named Laravel routes. Also provides a nice route() helper function in JavaScript.
Block routes by IP
Provides caching methods which can be easily used for caching routes.
End-to-end type-safe APIs for Laravel. Like tRPC, but for Laravel + TypeScript.
Alfabank REST API integration
统计信息
- 总下载量: 23
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-15