PHPackages                             maduser/argon-routing - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. maduser/argon-routing

ActiveLibrary[HTTP &amp; Networking](/categories/http)

maduser/argon-routing
=====================

HTTP routing layer for the Argon stack.

v1.0.0(2mo ago)0201MITPHPCI passing

Since May 24Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/judus/argon-routing)[ Packagist](https://packagist.org/packages/maduser/argon-routing)[ RSS](/packages/maduser-argon-routing/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (16)Versions (3)Used By (1)

Argon Routing
=============

[](#argon-routing)

[![PHP](https://camo.githubusercontent.com/ce3e396e4f1bbbd326f628872a1414656d28065f2712cda0868d8eff07320aec/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e322b2d626c7565)](https://www.php.net/)[![Build](https://github.com/judus/argon-routing/actions/workflows/php.yml/badge.svg)](https://github.com/judus/argon-routing/actions)[![codecov](https://camo.githubusercontent.com/d6aa8c14a9e6d11df0f7bb054fbe8b3cffc0e8dd3b9003850f296b575f8e066d/68747470733a2f2f636f6465636f762e696f2f67682f6a756475732f6172676f6e2d726f7574696e672f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/judus/argon-routing)[![Psalm Level](https://camo.githubusercontent.com/ab8efc1f82e779f422bd84889c55035a67eb9b3a0d10bb70a4641df47d0c0661/68747470733a2f2f73686570686572642e6465762f6769746875622f6a756475732f6172676f6e2d726f7574696e672f636f7665726167652e737667)](https://shepherd.dev/github/judus/argon-routing)[![Latest Version](https://camo.githubusercontent.com/85e5f48252eef3adf1e96f0b04c561eac71e6b403a27d4e8a8f3b04115949dfe/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6164757365722f6172676f6e2d726f7574696e672e737667)](https://packagist.org/packages/maduser/argon-routing)[![Downloads](https://camo.githubusercontent.com/552cba0b24055af0343c2cf3f9e070c11862475ef7148ee87d9dc13a44b1f9ff/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6164757365722f6172676f6e2d726f7574696e672e737667)](https://packagist.org/packages/maduser/argon-routing)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)

Argon Routing is the HTTP routing layer that powers the Argon ecosystem.
It is designed around the Argon container, the shared middleware pipeline, and the request-handler resolver. The library embraces those components to provide:

- auto-registration of routes in the container;
- seamless middleware stack compilation;
- request handler resolution that honours Argon’s logging and pipeline stages.

Because of those tight integrations, **Argon Routing is not intended for use outside the Argon stack**. It has hard runtime dependencies on:

- `maduser/argon-container` (service container and service providers);
- `maduser/argon-middleware` (pipeline manager/store).

If you need a framework-agnostic router, you should look at an alternative.

Installation
------------

[](#installation)

```
composer require maduser/argon-routing
```

Make sure your project already pulls in `maduser/argon-container` and `maduser/argon-middleware`; they are required at runtime. When developing locally inside the Argon monorepo, the path repositories configured there will resolve the packages automatically.

Quick Start
-----------

[](#quick-start)

```
use Maduser\Argon\Container\ArgonContainer;
use Maduser\Argon\Routing\Router;
use Maduser\Argon\Routing\RouteManager;
use Maduser\Argon\Routing\RouteMatcher;
use App\Http\Middleware\AuthMiddleware;
use App\Http\Middleware\CsrfMiddleware;
use Nyholm\Psr7\Factory\Psr17Factory;

$container = new ArgonContainer();
$routes = new RouteManager();                // defaults to the in-memory store
$router = new Router($container, $routes);

// Define routes just like in a typical HTTP kernel
$router->get('/users/{id}', 'UsersController@show', middleware: [AuthMiddleware::class]);
$router->post('/users', 'UsersController@store', middleware: [AuthMiddleware::class, CsrfMiddleware::class]);

// Match an incoming request
$psr17 = new Psr17Factory();
$request = $psr17->createServerRequest('GET', '/users/42');

$matcher = new RouteMatcher($routes);
$matched = $matcher->match($request);

// Inspect the matched route (all PSR types)
$matched->getHandler();      // UsersController@show
$matched->getArguments();    // ['id' => '42']
$matched->getMiddlewares();  // [AuthMiddleware::class]
```

Middleware passed to the router can be concrete middleware service IDs or group aliases from the container's `middleware.http` tag metadata. Route metadata stores the resolved container service IDs, not the original aliases, so the cached route stack can be handed directly to `maduser/argon-middleware`. Those service IDs may be concrete middleware classes or interfaces bound in the container.

Once you hand the `RouteManager` instance to Argon’s middleware pipeline and request-handler resolver (see the main Argon documentation), requests will flow through the registered middleware stacks and invoke your controllers through the container.

Handler Contract
----------------

[](#handler-contract)

Container-backed routes support these handler definitions:

```
$router->get('/health', HealthController::class);
$router->get('/users/{id}', [UsersController::class, 'show']);
$router->get('/articles/{slug}', ArticlesController::class . '@show');
```

Route placeholders are forwarded to the container invocation as named arguments. Controller methods should declare those placeholders directly:

```
final class UsersController
{
    public function show(string $id): array
    {
        return ['id' => $id];
    }
}
```

Do not expect a single `array $args` parameter in container-backed handlers. The container prepares controller invocations through reflection, so route arguments are mapped by name.

Not Found Contract
------------------

[](#not-found-contract)

When no route matches the incoming request, `RouteMatcher` throws `Maduser\Argon\Routing\Exception\RouteNotFoundException`. The exception carries code `404`, which lets Argon runtime error handlers render the failure as an HTTP not-found response instead of an internal-server-error.

Model / DTO Bindings via Interceptors
-------------------------------------

[](#model--dto-bindings-via-interceptors)

Frameworks such as Laravel or Symfony implement “route model binding” inside the router. In Argon the router keeps things agnostic: it forwards the raw route arguments (`['user' => '42']`) into the container, and **interceptors** take care of loading any richer objects you expect in your controllers.

```
// Register the interceptors that should run before your handlers are invoked.
// Each can examine the matched route from the request attribute, inspect payloads, etc.
$container->registerInterceptor(EntityBindingInterceptor::class);
$container->registerInterceptor(JsonPayloadInterceptor::class);
$container->registerInterceptor(RequestValidationInterceptor::class);

$router->get('/users/{user}', [UsersController::class, 'show']);

final class UsersController
{
    public function show(User $userDto): ResponseInterface
    {
        // $userDto already passed through the interceptors
    }
}
```

Instead of hard-coding a single binding strategy in the router, this approach lets you decide how arguments should be turned into rich objects: one interceptor may hydrate entities from IDs, another may validate and map JSON payloads into DTOs, others could parse XML or JSON-RPC requests. Because interceptors are just classes registered with the container, you can combine and layer them however you like. See the Argon container README for more patterns and advanced usage.

Notes
-----

[](#notes)

- The `InMemoryStore` bundled with the package exists to keep tests simple and for early prototyping; production builds should rely on the container-backed store registered by the `ArgonRoutingServiceProvider`.
- The `FileSystemStore` is a placeholder for potential standalone usage. It is not required when running inside Argon.
- Shared interfaces (such as `ResultContextInterface`) now ship with `maduser/argon-middleware`packages; make sure your project is aligned with the versions shipped there.

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance88

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

61d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7fb9da5a15010d335622bf9f465a32ef79c8d1cffcd139c2a9114736b72e2c13?d=identicon)[jdu](/maintainers/jdu)

---

Top Contributors

[![judus](https://avatars.githubusercontent.com/u/1478654?v=4)](https://github.com/judus "judus (42 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/maduser-argon-routing/health.svg)

```
[![Health](https://phpackages.com/badges/maduser-argon-routing/health.svg)](https://phpackages.com/packages/maduser-argon-routing)
```

###  Alternatives

[cakephp/cakephp

The CakePHP framework

8.8k19.5M1.8k](/packages/cakephp-cakephp)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[sunrise/http-router

A powerful solution as the foundation of your project.

17451.8k11](/packages/sunrise-http-router)[typo3/cms-core

TYPO3 CMS Core

3713.2M5.2k](/packages/typo3-cms-core)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k16](/packages/tempest-framework)[eliashaeussler/typo3-warming

Warming - Warms up Frontend caches based on an XML sitemap. Cache warmup can be triggered via TYPO3 backend or using a console command. Supports multiple languages and custom crawler implementations.

22260.2k](/packages/eliashaeussler-typo3-warming)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
