PHPackages                             burzum/fast-route-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. burzum/fast-route-middleware

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

burzum/fast-route-middleware
============================

29[1 PRs](https://github.com/burzum/fast-route-psr15-middleware/pulls)PHPCI failing

Since Dec 5Pushed 6y ago1 watchersCompare

[ Source](https://github.com/burzum/fast-route-psr15-middleware)[ Packagist](https://packagist.org/packages/burzum/fast-route-middleware)[ RSS](/packages/burzum-fast-route-middleware/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

Fast Route PSR 15 Middleware
============================

[](#fast-route-psr-15-middleware)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Scrutinizer Coverage](https://camo.githubusercontent.com/d8eba29acc78b9fff529116f8801b58fd42918acff93adbb0f922be91dcc43db/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6275727a756d2f666173742d726f7574652d70737231352d6d6964646c65776172652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/burzum/fast-route-psr15-middleware/)[![Code Quality](https://camo.githubusercontent.com/1d0ac46b1805448046359976124336591c70419ceab7a7f61f089c3777e87956/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6275727a756d2f666173742d726f7574652d70737231352d6d6964646c65776172652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/burzum/fast-route-psr15-middleware/)

A convenient and strict typed Fast Route middleware.

How to use it
-------------

[](#how-to-use-it)

Fast Routes result will be an array of which the first key represent the kind of result. Fast Route knows three different cases so far:

1. Route found
2. Route not found
3. Route not allowed

The middleware deals with getting this result for you from Fast Route but you'll have to to define your handlers, because this is up to you and your application. The middleware takes an object that needs to implement an interface specific to each time.

You **must** create at least the found handler! Each kind of handler must implement the according interface. The other two handlers are optional!

```
// Route was found and matched the URL
class MyFoundHandler implements FoundHandlerInterface
{
    public function handle(ServerRequestInterface $request, $handler, array $vars): ?ResponseInterface
    {
        // Handle the request and return null or a response object
        // Dispatch your controllers or request handlers here based on the route vars
    }
}

// Route was not found, URL didn't match
class MyNotFoundHandler implements NotFoundHandlerInterface
{
    public function handle(ServerRequestInterface $request): ?ResponseInterface
    {
        // Handle the request and return null or a response object
        // Dispatch your controllers or request handlers here
    }
}

// Route was found but is not allowed to be accessible
class MyNotAllowedHandler implements NotAllowedHandlerInterface
{
    public function handle(ServerRequestInterface $request, array $notAllowedMethods): ?ResponseInterface
    {
        // Handle the request and return null or a response object
        // Dispatch your controllers or request handlers here
    }
}
```

Then configure the middleware. You **must** pass a FoundHandler the other two are optional!

Check the [FastRoute documentation](https://github.com/nikic/FastRoute) for how to configure FastRoutes dispatcher and it's routes.

```
$dispatcher = SimpleDispatcher(function(RouteCollector $r) {
    // Your routes...
});

$fastRouteMiddleware = new FastRouteMiddleware(
    $dispatcher,
    new MyFoundHandler(),
    new MyNotFoundHandler(),
    new MyNotAllowedHandler()
);

// Pass the middleware to your middleware handler implementation
```

License
-------

[](#license)

MIT License

Copyright (c) 2018 by Florian Krämer.

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity37

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/0643e6255da841fe65260ec6e263d8908a40a84b884c32e9fc6be6a15e252fa8?d=identicon)[burzum](/maintainers/burzum)

---

Top Contributors

[![burzum](https://avatars.githubusercontent.com/u/162789?v=4)](https://github.com/burzum "burzum (6 commits)")

---

Tags

dispatcherfast-routemiddlewarephp7psrpsr-15routesrouting

### Embed Badge

![Health badge](/badges/burzum-fast-route-middleware/health.svg)

```
[![Health](https://phpackages.com/badges/burzum-fast-route-middleware/health.svg)](https://phpackages.com/packages/burzum-fast-route-middleware)
```

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M318](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[nyholm/psr7

A fast PHP7 implementation of PSR-7

1.3k235.4M2.4k](/packages/nyholm-psr7)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M292](/packages/pusher-pusher-php-server)[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78126.4M414](/packages/react-http)

PHPackages © 2026

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