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

ActiveLibrary

zhuksone/php-router
===================

Minimal router implementation for a php application

01PHP

Since Oct 3Pushed 2y ago1 watchersCompare

[ Source](https://github.com/zhuksone/PHP-Router)[ Packagist](https://packagist.org/packages/zhuksone/php-router)[ RSS](/packages/zhuksone-php-router/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

PHP-Router
==========

[](#php-router)

Minimal router implementation for a php application

Как использовать:
-----------------

[](#как-использовать)

### Шаг первый:

[](#шаг-первый)

```
Заполнить массив Router::$GET как показано на примере ниже,
своими URI/Controller/action/name/middleware

Router::GET('/', \yourNamespace\SomeController::class, 'action')
       ->name('nameThisURI')
       ->middleware('short_name_your_middleware' или ['short_name_your_middleware', 'second_short_name_your_middleware']);

Router::GET('/post/{post}/comment/{comment}', \PostsController::class, 'showComment')
       ->name('myNameForThisURI')
       ->middleware(['Authorization', 'Authentication']);

```

### Шаг второй:

[](#шаг-второй)

```
Заполнить массив Router::$middleware, как показано на примере ниже,
для будущей замены у конкретного $routeConfig его коротких имён middleware на полные

use Middleware;

Router::middleware('short_name_your_middleware', yourNamespace\SomeMiddleware::class);
Router::middleware('second_short_name_your_middleware', yourNamespace\SomeSecondMiddleware::class);
Router::middleware('Authorization', Authorization::class);
Router::middleware('Authentication', Authentication::class);

```

### Шаг третий:

[](#шаг-третий)

```
$routeConfig = Router::compareURI($_SERVER['REQUEST_URI']);

```

Шаг №1 и шаг №2 можно поменять местами. Главное, чтобы в момент вызова метода Router::compareURI($\_SERVER\['REQUEST\_URI'\]) короткие имена middleware и им принадлежащие классы уже были добавлены в массив

### Дамп $routeConfig для uri '/post/123/comment/456':

[](#дамп-routeconfig-для-uri-post123comment456)

```
RouteConfig:
     'uri'          =>  '/post/{post}/comment/{comment}',
     'className'    =>  'PostsController',
     'action'       =>  'showComment',
     'uri_name'     =>  'commentPost',
     'middleware'   =>  [
                0   =>  'Middleware\Authorization',
                1   =>  'Middleware\Authentication',
                ],
     'middlewareString' =>  false,
     'Comparisons'  =>  [
                 'post'     =>  '123',
                 'comment'  =>  '456',
                 ],

```

#### В поле 'Comparisons' нам доступны значения по именам, которые мы указали при назначении роута определённому uri:

[](#в-поле-comparisons-нам-доступны-значения-по-именам-которые-мы-указали-при-назначении-роута-определённому-uri)

```
Router::GET('/myRoute/{intKey}/', \SomeController::class, 'action')

```

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity21

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/bfde599146c6890f946ecd7dddcdd3c7f64649f69992d4fdc89b0df956cbd220?d=identicon)[zhuksone](/maintainers/zhuksone)

---

Top Contributors

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

### Embed Badge

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

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

PHPackages © 2026

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