PHPackages                             borschphp/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. borschphp/router

ActiveLibrary

borschphp/router
================

A FastRoute router implementation.

3.2.0(7mo ago)11.3k↑1135.3%[1 PRs](https://github.com/borschphp/borsch-router/pulls)1MITPHPPHP ^8.2CI passing

Since May 27Pushed 7mo agoCompare

[ Source](https://github.com/borschphp/borsch-router)[ Packagist](https://packagist.org/packages/borschphp/router)[ RSS](/packages/borschphp-router/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (8)Versions (24)Used By (1)

[![PHP Composer](https://github.com/borschphp/borsch-router/actions/workflows/php.yml/badge.svg)](https://github.com/borschphp/borsch-router/actions/workflows/php.yml)[![Latest Stable Version](https://camo.githubusercontent.com/4598ccb924833504a6f3b3acc9eff12fd03e86dbc71d77f0708f1de469de3d88/68747470733a2f2f706f7365722e707567782e6f72672f626f727363687068702f726f757465722f76)](//packagist.org/packages/borschphp/router)[![License](https://camo.githubusercontent.com/84123abc2c1070f5dd2036ca65b5d75ef09d6be74f9cecc6af280fd3067023ab/68747470733a2f2f706f7365722e707567782e6f72672f626f727363687068702f726f757465722f6c6963656e7365)](//packagist.org/packages/borschphp/router)

### Borsch Router

[](#borsch-router)

 An awesome router implementation with support for multiple routing engines, including `nikic/fast-route`.

 Table of Contents1. [About The Project](#about-the-project)
2. [Getting Started](#getting-started)
    - [Prerequisites](#prerequisites)
    - [Installation](#installation)
3. [Usage](#usage)
4. [Testing](#testing)
5. [Contributing](#contributing)
6. [License](#license)
7. [Acknowledgments](#acknowledgments)

About The Project
-----------------

[](#about-the-project)

A collection of router implementations, inspired by the one you can find in the excellent [Mezzio Routing Interfaces](https://docs.mezzio.dev/mezzio/v3/features/router/interface/). Among them :

- a router is based on [nikic/fast-route](https://github.com/nikic/FastRoute)
- a router is based on a tree structure
- a router is based on a simple comparator

You need to provide a PSR-7 ServerRequestInterface in order to match the routes.
A PSR-7 ResponseInterface must be returned by the route handler.

([back to top](#readme-top))

Getting Started
---------------

[](#getting-started)

### Prerequisites

[](#prerequisites)

You need `PHP >= 8.2` to use `Borsch\Router` but the latest stable version of PHP is always recommended.

It also requires an implementation of PSR-7 HTTP Message.
The Laminas Diactoros Project is used for testing, and in the examples below.

### Installation

[](#installation)

Via [composer](https://getcomposer.org/) :

`composer require borschphp/router`

([back to top](#readme-top))

Usage
-----

[](#usage)

```
require_once __DIR__.'/vendor/autoload.php';

$router = new \Borsch\Router\FastRouteRouter();

$router->addRoute(new \Borsch\Router\Route(
    ['GET'],
    '/articles/{id:\d+}[/{slug}]',
    new ArticleHandler(), // Instance of RequestHandlerInterface
    'articles.id.title'
));

$server_request = \Laminas\Diactoros\ServerRequestFactory::fromGlobals();

// $route_result is an instance of RouteResultInterface
$route_result = $router->match($server_request);

// $route is an instance of RouteInterface (or false if no match)
$route = $route_result->getMatchedRoute();
if (!$route) {
    return new \Laminas\Diactoros\Response('Not Found', 404);
}

// $response is an instance of ResponseInterface
$response = $route->getHandler()->handle($server_request);

// Send the response back to the client or other...
```

### Available routers

[](#available-routers)

Router NameDescriptionCacheSpeedSpeed with cacheVariablesOptional Parts`FastRouteRouter`A `nikic/fast-route` based router✅MediumFast✅✅`TreeRouter`A tree based router✅FastVery fast✅❌`SimpleConditionalRouter`A very simple comparator based router❌Very fast❌❌❌([back to top](#readme-top))

Testing
-------

[](#testing)

This package uses `Pest` as test framework.
To run tests :

```
./vendor/bin/pest tests
```

Mutation testing has also been added to this package:

```
XDEBUG_MODE=coverage ./vendor/bin/pest --mutate --parallel
```

([back to top](#readme-top))

Contributing
------------

[](#contributing)

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

([back to top](#readme-top))

License
-------

[](#license)

Distributed under the MIT License. See [License File](https://github.com/borschphp/borsch-router/blob/master/LICENSE.md) for more information.

([back to top](#readme-top))

Acknowledgments
---------------

[](#acknowledgments)

A big thanks to these projects for inspiration or because they're used in this one:

- [nikic/fast-route](https://github.com/nikic/FastRoute)
- [Mezzio Routing Interface](https://docs.mezzio.dev/mezzio/v3/features/router/interface/)
- [PHP Standards Recommendations](https://www.php-fig.org/psr/)

([back to top](#readme-top))

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance62

Regular maintenance activity

Popularity19

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity77

Established project with proven stability

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

Recently: every ~30 days

Total

13

Last Release

230d ago

Major Versions

0.1.1 → 1.0.02022-07-01

1.1.0 → 2.0.02023-09-24

2.1.1 → v3.x-dev2025-04-06

PHP version history (5 changes)0.1PHP ^7.2

0.1.1PHP ^7.2|^8.0

1.0.0PHP ^8.0

2.1.0PHP ^8.1

v3.x-devPHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/0e1a70117520fe10a630d61c750bbe6888d174e9903825e741470f818ee2c5d1?d=identicon)[debuss-a](/maintainers/debuss-a)

---

Top Contributors

[![debuss](https://avatars.githubusercontent.com/u/2537607?v=4)](https://github.com/debuss "debuss (32 commits)")

###  Code Quality

TestsPest

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[slim/slim

Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs

12.2k49.0M1.2k](/packages/slim-slim)[mix/mix

PHP CLI mode development framework

1.9k1.2k](/packages/mix-mix)

PHPackages © 2026

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