archer-framework/router
最新稳定版本:v1.0.0
Composer 安装命令:
composer require archer-framework/router
包简介
This package contains modern interfaces and implementations for a context agnostic router
README 文档
README
This package defines contracts and a generic implementation for a context-agnostic router. It provides generic routing logic, that way, you can route http requests as well as CLI requests with the same router.
Install
Using composer:
composer require archer-framework/router
Usage
This package provides a clean and simple routing API.
Note that
RouteandContextimplementations are up to you, only contracts are provided by this package.
<?php
declare(strict_types=1);
$routes = [ ... ];
$router = new Router($routes);
// Dispatch a route matching context (if any)
$context = ...;
$dispatched = $router->resolve($context);
You can also add routes after initialization using the register method.
<?php
declare(strict_types=1);
$router = new Router();
// Adds a route after initialization
$route = ...;
$router->register($route);
This implementation will throw an exception if no route is found or multiple routes match the same context.
Check out the tests for more details.
License
This package is licensed under the MIT license.
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-09