This package contains modern interfaces and implementations for a context agnostic router

Installs: 1

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Forks: 0

pkg:composer/archer-framework/router

v1.0.0 2026-01-09 11:45 UTC

This package is auto-updated.

Last update: 2026-01-09 10:48:11 UTC


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 Route and Context implementations 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.