PHPackages                             kuick/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. [API Development](/categories/api)
4. /
5. kuick/routing

ActiveLibrary[API Development](/categories/api)

kuick/routing
=============

Routing package implementing PSR-15 middleware interface

v1.2.2(1mo ago)15.8k1MITPHPPHP &gt;=8.2.0CI passing

Since Jan 22Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/milejko/kuick-routing)[ Packagist](https://packagist.org/packages/kuick/routing)[ RSS](/packages/kuick-routing/feed)WikiDiscussions main Synced today

READMEChangelog (6)Dependencies (6)Versions (7)Used By (1)

Kuick Routing
=============

[](#kuick-routing)

[![Latest Version](https://camo.githubusercontent.com/4a60e7366f2c5630e8552b18a5164509d56e7c7507124cc07091085ddef22e7b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6d696c656a6b6f2f6b7569636b2d726f7574696e672e7376673f63616368655365636f6e64733d33363030)](https://github.com/milejko/kuick-routing/releases)[![PHP](https://camo.githubusercontent.com/ac99b489f44f6ce512b6a4d6919492f00b43862f88161b80e35da61f35064ca0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e32253230253743253230382e33253230253743253230382e34253230253743253230382e352d626c75653f6c6f676f3d7068702663616368655365636f6e64733d33363030)](https://www.php.net)[![Total Downloads](https://camo.githubusercontent.com/93eb32df156ef12f8844cceaaff81e605a651e5b10725b3106be0b691476758b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b7569636b2f726f7574696e672e7376673f63616368655365636f6e64733d33363030)](https://packagist.org/packages/kuick/routing)[![GitHub Actions CI](https://github.com/milejko/kuick-routing/actions/workflows/ci.yml/badge.svg)](https://github.com/milejko/kuick-routing/actions/workflows/ci.yml)[![codecov](https://camo.githubusercontent.com/f2908108ade6f4bbbe38efe39539915aa5b5c26fb2c3c2a4bd395fab966f21a2/68747470733a2f2f636f6465636f762e696f2f67682f6d696c656a6b6f2f6b7569636b2d726f7574696e672f67726170682f62616467652e7376673f746f6b656e3d4d3346573358594a354a)](https://codecov.io/gh/milejko/kuick-routing)[![Software License](https://camo.githubusercontent.com/e2f0982d826e942af97a6e879597c2301c2a8a97567d69e47148db858bbc5de3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f63616368655365636f6e64733d3134343030)](LICENSE)

Routing package implementing PSR-15 middleware
----------------------------------------------

[](#routing-package-implementing-psr-15-middleware)

### Key features

[](#key-features)

1. PSR-15() routing middleware implementation
2. Support for flexible Routes (any callable)
3. Router service for matching Routes to the Request
4. Routes supporting regex paths with named parameters

### Installation

[](#installation)

```
composer require kuick/routing
```

### Usage

[](#usage)

#### 1. Define controllers

[](#1-define-controllers)

Controllers are any callable (closure, invokable class, etc.) that accept a `ServerRequestInterface` and return a `ResponseInterface`:

```
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;

$helloController = function (ServerRequestInterface $request): ResponseInterface {
    $name = $request->getQueryParams()['name'] ?? 'World';
    return new \Kuick\Http\Message\Response(200, [], "Hello, $name!");
};

// Invokable class example
class GetUserAction
{
    public function __invoke(ServerRequestInterface $request): ResponseInterface
    {
        $id = $request->getQueryParams()['id'];
        return new \Kuick\Http\Message\Response(200, [], "User: $id");
    }
}
```

#### 2. Set up the Router

[](#2-set-up-the-router)

Use `Router::addRoute(path, controller, methods)` to register routes. The `path` supports regex with named capture groups for dynamic segments:

```
use Kuick\Routing\Router;
use Psr\Log\NullLogger;

$router = (new Router(new NullLogger()))
    ->addRoute('/', $helloController, ['GET'])
    ->addRoute('/users/(?P\d+)', new GetUserAction(), ['GET'])
    ->addRoute('/articles', $listArticlesController, ['GET', 'POST']);
```

Named regex groups (e.g. `(?P\d+)`) are merged into the request's query params and accessible via `$request->getQueryParams()['id']`.

#### 3. Use as a PSR-15 middleware

[](#3-use-as-a-psr-15-middleware)

Wire `RoutingMiddleware` into your middleware pipeline. When a route matches, the controller is invoked and its response returned; otherwise the next handler in the chain is called:

```
use Kuick\Routing\Router;
use Kuick\Routing\RoutingMiddleware;
use Psr\Log\NullLogger;

$router = (new Router(new NullLogger()))
    ->addRoute('/users/(?P\d+)', new GetUserAction(), ['GET']);

$middleware = new RoutingMiddleware($router, new NullLogger());

// $handler is the next PSR-15 RequestHandlerInterface in the pipeline
$response = $middleware->process($request, $handler);
```

#### Notes

[](#notes)

- Route paths are matched as full regex anchors (`^pattern$`), so no partial matches occur.
- A trailing `/` is stripped from the request path before matching (except for the root `/`).
- `HEAD` is automatically supported for any route that accepts `GET`.
- When no route matches, the request is forwarded to the next `RequestHandlerInterface`.

###  Health Score

48

—

FairBetter than 93% of packages

Maintenance90

Actively maintained with recent releases

Popularity25

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

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

Recently: every ~117 days

Total

6

Last Release

51d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f986340afe26a382bdec4d838f514714b6f5bc7222baf73972001a66b9b6dab0?d=identicon)[emisarius](/maintainers/emisarius)

---

Top Contributors

[![milejko](https://avatars.githubusercontent.com/u/14335568?v=4)](https://github.com/milejko "milejko (9 commits)")

---

Tags

middlewareroutingpsr-15Kuick

### Embed Badge

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

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

###  Alternatives

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[algolia/algoliasearch-client-php

API powering the features of Algolia.

69735.1M159](/packages/algolia-algoliasearch-client-php)[avalara/avataxclient

Client library for Avalara's AvaTax suite of business tax calculation and processing services. Uses the REST v2 API.

528.5M7](/packages/avalara-avataxclient)[keboola/storage-api-client

Keboola Storage API PHP Client

10405.9k39](/packages/keboola-storage-api-client)

PHPackages © 2026

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