getphred/atlas
Composer 安装命令:
composer require getphred/atlas
包简介
A high-performance, modular PHP routing engine with PSR-7 support.
README 文档
README
A high-performance, modular PHP routing engine designed for professional-grade applications. It prioritizes developer experience, architectural purity, and interoperability through PSR-7 support.
Features
- Fluent API: Expressive and chainable route definitions.
- Dynamic Matching: Support for
{{parameters}}and{{optional?}}segments. - Parameter Validation: Strict validation rules (numeric, alpha, regex, etc.).
- Route Groups: Recursive grouping with prefix and middleware inheritance.
- Modular Routing: Automatic route discovery from modules.
- Reverse Routing: Safe URL generation with parameter validation.
- PSR-7 Support: Built on standard HTTP message interfaces.
- Advanced Capabilities: Subdomain constraints, i18n support, and redirects.
- Developer Tooling: Programmatic Inspector API and CLI tools.
- Performance: Optimized matching engine with route caching support.
Installation
composer require getphred/atlas
Basic Usage
use Atlas\Router\Router; use Atlas\Config\Config; use GuzzleHttp\Psr7\ServerRequest; // 1. Setup Configuration $config = new Config([ 'modules_path' => __DIR__ . '/src/Modules', ]); // 2. Initialize Router $router = new Router($config); // 3. Define Routes $router->get('/users', function() { return 'User List'; })->name('users.index'); $router->get('/users/{{id}}', function($id) { return "User $id"; })->name('users.show')->valid('id', 'numeric'); // 4. Match Request $request = ServerRequest::fromGlobals(); $route = $router->match($request); if ($route) { $handler = $route->getHandler(); // Execute handler... } else { // 404 Not Found }
Route Groups
$router->group(['prefix' => '/api', 'middleware' => ['auth']])->group(function($group) { $group->get('/profile', 'ProfileHandler'); $group->get('/settings', 'SettingsHandler'); });
All group routes inherit whatever options you pass in (middleware, prefix, etc).
While the above syntax works and is completely viable, I find the double group method syntax a bit confusing.
So, here is another way you can do it (my personal preferred method) that is, in my opinion, cleaner, and more readable.
$api = $router->group(['prefix' => '/api']); $api->get('/users', 'UserIndexHandler'); $api->post('/users', 'UserCreateHandler');
Performance & Caching
For production environments, you can cache the route collection:
if ($cache->has('routes')) { $routes = unserialize($cache->get('routes')); $router->setRoutes($routes); } else { // Define your routes... $cache->set('routes', serialize($router->getRoutes())); }
CLI Tools
Atlas comes with a CLI tool to help you debug your routes:
# List all routes ./atlas route:list # Test a specific request ./atlas route:test GET /users/5
License
The MIT License (MIT). Please see License File for more information.
getphred/atlas 适用场景与选型建议
getphred/atlas 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 getphred/atlas 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 getphred/atlas 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 25
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-15