PHPackages                             alexpts/php-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. [HTTP &amp; Networking](/categories/http)
4. /
5. alexpts/php-routing

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

alexpts/php-routing
===================

Simple router compatible with the PSR-7

1.0.0(8y ago)2120MITPHPPHP &gt;=7.1

Since Apr 20Pushed 8y ago1 watchersCompare

[ Source](https://github.com/alexpts/php-routing)[ Packagist](https://packagist.org/packages/alexpts/php-routing)[ Docs](https://github.com/alexpts/php-routing)[ RSS](/packages/alexpts-php-routing/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (4)Dependencies (4)Versions (5)Used By (0)

php-routing
===========

[](#php-routing)

[![SensioLabsInsight](https://camo.githubusercontent.com/32b5205313fc5d095bd489e500831908c85cbab1952b272e12a639e0d4b09439/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f38393831326563632d626162622d343431652d616363612d3436366338376530336135342f6269672e706e67)](https://insight.sensiolabs.com/projects/89812ecc-babb-441e-acca-466c87e03a54)

[![Build Status](https://camo.githubusercontent.com/736c637ebb407fc7fee5136d937bbac6cdbfe4fb6527e9f7d19554ea668d889b/68747470733a2f2f7472617669732d63692e6f72672f616c65787074732f7068702d726f7574696e672e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/alexpts/php-routing)[![Code Coverage](https://camo.githubusercontent.com/8b99d1ab3726b5dde1e5eb281e966872a61c3a52cd8134094a5d2383103a0bbb/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f616c65787074732f7068702d726f7574696e672f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/alexpts/php-routing/?branch=master)[![Code Climate](https://camo.githubusercontent.com/d279e29f8999bd27adbc40c028a8877a504bbd46fa34d024e00db427b673cb51/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f616c65787074732f7068702d726f7574696e672f6261646765732f6770612e737667)](https://codeclimate.com/github/alexpts/php-routing)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/e6d5d6ff9d7a81a9c003765c8abce82c7e598d0fbbde2a81606b8225bea6237c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f616c65787074732f7068702d726f7574696e672f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/alexpts/php-routing/?branch=master)

Простой роутер с поддержкой PSR-7 и middelware на уровне роута.

#### Возможности

[](#возможности)

- Простой захват параметров из url
- Использование RegExp для описания роута
- Гибкие группировки для захвата параметров
- Приоритеты роутов
- Middlewares на уровне роутов
- Высокая скорость работы
- Указание дефолтного роута
- Адаптирован для работы с REST

#### Простой роутинг

[](#простой-роутинг)

```
use PTS\Routing\Route;
use PTS\Routing\CollectionRoute;
use PTS\Routing\Matcher;
use PTS\Routing\RouteService;
use Psr\Http\Message\RequestInterface;

$route = new Route('/', function() {
    return ['response' => 'data'];
});
$collection = new CollectionRoute();
$collection->add('main', $route);
$matcher = new Matcher(new RouteService());

$activeRoute = $matcher->match($collection, '/')->current();
$response = $activeRoute($request); // PSR-7 request
```

#### Захват параметров из url

[](#захват-параметров-из-url)

Захваченные параметры могут быть переданы в качестве аргументов в обработчик. Параметры начинающиеся с символа `_` игнорируются. Они нужны для технических нужд.

```
use PTS\Routing\Route;
use PTS\Routing\CollectionRoute;
use PTS\Routing\Matcher;
use PTS\Routing\RouteService;
use Psr\Http\Message\RequestInterface;

$route = new Route('/users/{userId}/', function($userId) {
    return $userId;
});
$route->pushMiddleware(new CallWithMatchParams);

$collection = new CollectionRoute();
$collection->add('user', $route);
$matcher = new Matcher(new RouteService());

$activeRoute = $matcher->match($collection, '/users/4/')->current();
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity61

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

Total

4

Last Release

3170d ago

PHP version history (2 changes)1.0.0-RC1PHP &gt;=7.0

1.0.0-RC3PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/31106536118e11bf9d0c9d7f467db5b534efa9c46ee76680b308f0c39d9a798c?d=identicon)[alexpts](/maintainers/alexpts)

---

Tags

psr-7router

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[league/route

Fast routing and dispatch component including PSR-15 middleware, built on top of FastRoute.

6633.1M116](/packages/league-route)[aura/router

Powerful, flexible web routing for PSR-7 requests.

5231.5M67](/packages/aura-router)[sunrise/http-router

A powerful solution as the foundation of your project.

16249.8k10](/packages/sunrise-http-router)[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)

PHPackages © 2026

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