PHPackages                             mizmoz/router - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. mizmoz/router

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mizmoz/router
=============

Mizmoz Router

1.0.0(1y ago)0691MITPHPPHP &gt;=8.3

Since Aug 30Pushed 1y ago1 watchersCompare

[ Source](https://github.com/mizmoz/router)[ Packagist](https://packagist.org/packages/mizmoz/router)[ RSS](/packages/mizmoz-router/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (6)Versions (8)Used By (1)

[Mizmoz](https://www.mizmoz.com) / Router
=========================================

[](#mizmoz--router)

A Simple Router for HTTP

Aims
----

[](#aims)

- Be lightweight
- Use PSR-7 HTTP message interfaces
- Use PSR-15 HTTP server middleware (when it becomes standardised, maybe, it's a mess right now)
- Resolution with PSR-11: Container interface

Basic Usage
-----------

[](#basic-usage)

```
// create a simple route
$route = Route::get('/', function (RequestInterface $request, ResponseInterface $response, ResultInterface $result) {
  return $response;
});

// init with a PSR-11 compatible container for class resolution
$dispatcher = new Router($route, $container);

// dispatch the route by passing a PSR-7 compatible Request
$response = $dispatcher->dispatch(new ServerRequest('GET', '/'));

exit($response->getBody()->getContents());
```

#### More examples

[](#more-examples)

```
// class callback which will call the default process($request, $response, $next);
Route::get('/admin', AdminController::class);

// class callback with specific method
Route::get('/admin', [AdminController::class, 'home']);

// Route to app\actions\User\GetProfile.php
Route::get('/profile/{:userId}', 'User\GetProfile');

// A more complete route
Route::get('/', HomePage::class, function (RouteInterface $r) {
    // add some child routes
    $r->addRoute('GET', '/profile', ...);
});

// wildcard matching
Route::get('/app/*', AppController::class);
```

#### Routes with variables

[](#routes-with-variables)

```
// create the route with simple variable matching using :variable format
$route = new Route('GET', '/users/:userId', UserGet::class);

// get the variable
$userId = $route->match('GET', '/users/123')->getVariable('userId');
```

#### Get the route result object from the request either in the route endpoint or middleware

[](#get-the-route-result-object-from-the-request-either-in-the-route-endpoint-or-middleware)

```
public function myMethod(ServerRequestInterface $request, ...)
{
    var_dump($request->getAttribute(Dispatcher::ATTRIBUTE_RESULT_KEY));
}
```

#### Middleware

[](#middleware)

```
// add global middleware
$router->addMiddleware(new EnsureSsl());

// add middlware to a route, middleware is added before the route definition by default
$router->get('admin', AdminController::class)
    ->addMiddleware(new EnsureSsl());

// add to all routes
$router->get('/', function (RouteInterface $r) {
    $r->get('/users', ...);
})->addMiddleware(new AclUser('admin'));
```

Roadmap
-------

[](#roadmap)

- Add REST API helper for classes
- Allow fallback / catch all / error routes

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity83

Battle-tested with a long release history

 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

Every ~431 days

Recently: every ~646 days

Total

7

Last Release

594d ago

Major Versions

0.5.0 → 1.0.02024-09-27

PHP version history (2 changes)0.1.0PHP &gt;=7.0

1.0.0PHP &gt;=8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/37a90e0c6130970a2e26b9ed1ed93a0a95588d7f07a4c166067aec064fd82d4b?d=identicon)[ianchadwick](/maintainers/ianchadwick)

---

Top Contributors

[![ianchadwick](https://avatars.githubusercontent.com/u/733223?v=4)](https://github.com/ianchadwick "ianchadwick (3 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/mizmoz-router/health.svg)

```
[![Health](https://phpackages.com/badges/mizmoz-router/health.svg)](https://phpackages.com/packages/mizmoz-router)
```

###  Alternatives

[google/cloud-core

Google Cloud PHP shared dependency, providing functionality useful to all components.

343121.4M79](/packages/google-cloud-core)[silverstripe/framework

The SilverStripe framework

7213.5M2.5k](/packages/silverstripe-framework)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k20](/packages/civicrm-civicrm-core)[wallabag/wallabag

open source self hostable read-it-later web application

12.6k2.2k](/packages/wallabag-wallabag)[jaxon-php/jaxon-core

Jaxon is an open source PHP library for easily creating Ajax web applications

73142.3k25](/packages/jaxon-php-jaxon-core)[neos/flow-development-collection

Flow packages in a joined repository for pull requests.

144179.3k3](/packages/neos-flow-development-collection)

PHPackages © 2026

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