PHPackages                             solophp/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. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. solophp/router

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

solophp/router
==============

A high-performance PHP router with middleware support, route groups, named routes, and advanced optional segment patterns.

v3.1.0(1w ago)390↓100%MITPHPPHP &gt;=8.1CI passing

Since Dec 15Pushed 1w ago1 watchersCompare

[ Source](https://github.com/SoloPHP/Router)[ Packagist](https://packagist.org/packages/solophp/router)[ RSS](/packages/solophp-router/feed)WikiDiscussions main Synced today

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

Solo Router
===========

[](#solo-router)

High-performance PHP router with middleware support, route groups, named routes, and advanced optional segment patterns.

[![Latest Version on Packagist](https://camo.githubusercontent.com/ae30ae209078b40f5a6f1892a0865eeedcaf6e04b796e64a9fe67a8e670add7b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736f6c6f7068702f726f757465722e737667)](https://packagist.org/packages/solophp/router)[![PHP Version](https://camo.githubusercontent.com/b0b6d5f16e83ecdb2339571189bb6e44a49e79db7b8e5bddf8a9530c7442eb54/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312532422d3838393242462e737667)](https://php.net/)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](LICENSE)

Features
--------

[](#features)

- **High Performance** — Static routes use O(1) hash lookup, pattern caching
- **Fluent API** — Chainable `->name()` and `->middleware()` methods
- **Route Groups** — Shared prefixes and middleware with nesting
- **Middleware** — Single and multiple middleware per route/group
- **Advanced Patterns** — Optional segments anywhere, nested optionals, regex constraints
- **Named Routes** — Easy route referencing for URL generation

Installation
------------

[](#installation)

```
composer require solophp/router
```

Quick Example
-------------

[](#quick-example)

```
use Solo\Router\RouteCollector;

$router = new RouteCollector();

// Simple routes
$router->get('/users', [UserController::class, 'index']);
$router->get('/users/{id}', [UserController::class, 'show']);

// Route with middleware and name
$router->post('/posts', [PostController::class, 'store'])
    ->middleware(AuthMiddleware::class)
    ->name('posts.store');

// Route groups
$router->group('/admin', function(RouteCollector $router) {
    $router->get('/dashboard', [AdminController::class, 'dashboard']);
    $router->get('/users', [AdminController::class, 'users']);
}, [AuthMiddleware::class]);

// Match request
$match = $router->match('GET', '/users/123');
if ($match) {
    $handler = $match['handler'];
    $params = $match['params'];       // ['id' => '123']
    $middlewares = $match['middlewares'];
    $name = $match['name'];           // route name or null
}
```

Documentation
-------------

[](#documentation)

**[Full Documentation](https://solophp.github.io/Router/)**

- [Installation](https://solophp.github.io/Router/guide/installation)
- [Quick Start](https://solophp.github.io/Router/guide/quick-start)
- [Handlers](https://solophp.github.io/Router/guide/handlers)
- [Route Parameters](https://solophp.github.io/Router/features/parameters)
- [Optional Segments](https://solophp.github.io/Router/features/optional-segments)
- [Route Groups](https://solophp.github.io/Router/features/groups)
- [Middleware](https://solophp.github.io/Router/features/middleware)
- [Named Routes](https://solophp.github.io/Router/features/named-routes)
- [API Reference](https://solophp.github.io/Router/api/router)

Requirements
------------

[](#requirements)

- PHP 8.1+

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE) for details.

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance98

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

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

Recently: every ~103 days

Total

6

Last Release

10d ago

Major Versions

v1.1.0 → v2.0.02025-10-16

v2.1.0 → v3.0.02025-12-06

### Community

Maintainers

![](https://www.gravatar.com/avatar/2f29817cec408d033cd4441c8f760e3ae40248dc0f66856a09080d282aee6959?d=identicon)[Vitaliy Olos](/maintainers/Vitaliy%20Olos)

---

Top Contributors

[![SoloPHP](https://avatars.githubusercontent.com/u/175482616?v=4)](https://github.com/SoloPHP "SoloPHP (15 commits)")

---

Tags

middlewarerouterroutingPSR-4php8php-routernamed routesroute-groups

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

PHPackages © 2026

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