PHPackages                             jowy/routing-middleware - 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. jowy/routing-middleware

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

jowy/routing-middleware
=======================

PSR 7 routing middleware

v1.0.1(10y ago)023MITPHPPHP &gt;=5.5.0

Since Jun 24Pushed 10y ago1 watchersCompare

[ Source](https://github.com/Atriedes/routing-middleware)[ Packagist](https://packagist.org/packages/jowy/routing-middleware)[ RSS](/packages/jowy-routing-middleware/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (7)Versions (4)Used By (0)

Routing Middleware
==================

[](#routing-middleware)

[![Build Status](https://camo.githubusercontent.com/4dfc1feb2b0839ecd55e76a9f489afd934712f2d5c187880a779ae11039c9234/68747470733a2f2f7472617669732d63692e6f72672f41747269656465732f726f7574696e672d6d6964646c65776172652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Atriedes/routing-middleware)

PSR 7 routing middleware based on [nikic/fast-route](https://github.com/nikic/FastRoute)

Installation &amp; Requirements
-------------------------------

[](#installation--requirements)

Install using composer

```
$ composer require jowy/routing-middleware
```

This library has following dependencies:

- `zendframework/zend-diactoros`, used for PSR 7 implementation
- `zendframework/zend-stratigility`, provide abstraction for PSR 7 middleware
- `nikic/fast-route`, used for routing
- `doctrine/cache`, used for caching routes

Usage
-----

[](#usage)

Usage on `zendframework/zend-stratigility`

```
use Zend\Stratigility\MiddlewarePipe;
use Jowy\Routing\Routing;

$app = new MiddlewarePipe();
$route_middleware = new Routing($options);

$app->pipe($route_middleware);
```

Usage on `relay/relay`

It advised to use container to resolve middleware when using `relay/relay`

```
use Pimple\Container;
use Relay\Relay;
use Jowy\Routing\Routing;

$container = new Container();

$container["middleware"] = [
    Routing::class => function() {
        return new Routing($options);
    }
];

$resolver = function ($class) use ($container) {
    return $container[$class];
}

new Relay(array_keys($container["middleware"], $resolver);
```

Options
-------

[](#options)

All options is in array, with key =&gt; value format.

- **collection** (callable or string) contains registered route from `RouteCollector`

    ```
    [
        "collection" => function (RouteCollector $collector) {
            $collector->addRoute("GET", "/", function (ServerRequestInterface $req, ResponseInterface $res) {
                return $res;
            });
            $collector->addRoute("GET", "/home", function (ServerRequestInterface $req, ResponseInterface $res) {
                return $res;
            });
        }
    ]
    ```

    optionally you use class instead of closure for handling matched request

    ```
    [
        "collection" => function (RouteCollector $collector) {
            $collector->addRoute("GET", "/", "Fully\\Qualified\\ClassName:yourMethod");
        }
    ]
    ```
- **generator** (object) implementation of `FastRoute\DataGenerator`

    ```
    [
        "generator" => new FastRoute\DataGenerator\GroupCountBased();
    ]
    ```
- **parser** (object) implementation of `FastRoute\RouteParser`

    ```
    [
        "parser" => new FastRoute\RouteParser\Std();
    ]
    ```
- **dispatcher** (callable) callable that return implementation of `FastRoute\Dispatcher`

    ```
    [
        "dispatcher" => function ($dispatch_data) {
            return new FastRoute\Dispatcher\GroupCountBased($dispatch_data);
        }
    ]
    ```
- **cache** (boolean) toggle routes caching, default value is false

    ```
    [
        "cache" => true
    ]
    ```
- **cacheDriver** (object) if `cache` is enabled you have to pass this param to options. It must contain implementation of `Doctrine\Common\Cache\Cache`

    ```
    [
        "cacheDriver" => new ArrayCache()
    ]
    ```

License
-------

[](#license)

MIT, see LICENSE

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity60

Established project with proven stability

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 ~1 days

Total

2

Last Release

3981d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/023a0bd17758df473ae6dad9f07575a8d0a8c36b06e83396b5962aecba38c722?d=identicon)[PrasWicaksono](/maintainers/PrasWicaksono)

---

Tags

middlewarepsr7routing

### Embed Badge

![Health badge](/badges/jowy-routing-middleware/health.svg)

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

###  Alternatives

[kevinrob/guzzle-cache-middleware

A HTTP/1.1 Cache for Guzzle 6. It's a simple Middleware to be added in the HandlerStack. (RFC 7234)

43417.4M104](/packages/kevinrob-guzzle-cache-middleware)[akrabat/ip-address-middleware

PSR-15 middleware that determines the client IP address and stores it as a ServerRequest attribute

1702.5M18](/packages/akrabat-ip-address-middleware)[rtheunissen/guzzle-log-middleware

Guzzle middleware to log requests and responses

842.3M17](/packages/rtheunissen-guzzle-log-middleware)[chadicus/slim-oauth2

OAuth2 routes, middleware and utilities for use within a Slim Framework API

129365.9k3](/packages/chadicus-slim-oauth2)[eljam/guzzle-jwt-middleware

A jwt authentication middleware for guzzle 6

28722.5k3](/packages/eljam-guzzle-jwt-middleware)[rtheunissen/guzzle-rate-limiter

Guzzle 6 middleware used to delay requests dynamically

52177.2k1](/packages/rtheunissen-guzzle-rate-limiter)

PHPackages © 2026

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