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

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

rudra/router
============

Rudra framework

v26.5(1mo ago)19051MPL-2.0PHPPHP &gt;=8.3CI passing

Since Jun 26Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/Jagepard/Rudra-Router)[ Packagist](https://packagist.org/packages/rudra/router)[ RSS](/packages/rudra-router/feed)WikiDiscussions master Synced 4w ago

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

[![PHPunit](https://github.com/Jagepard/Rudra-Router/actions/workflows/php.yml/badge.svg)](https://github.com/Jagepard/Rudra-Router/actions/workflows/php.yml)[![Maintainability](https://camo.githubusercontent.com/b69c0e568f668d995d54d2541307cfba206549f823832ad00d8f4b7e46e6cd4e/68747470733a2f2f716c74792e73682f6261646765732f64393235323131342d356363342d343035652d626266372d3634313965633530323636662f6d61696e7461696e6162696c6974792e737667)](https://qlty.sh/gh/Jagepard/projects/Rudra-Router)[![CodeFactor](https://camo.githubusercontent.com/a95bde2d37ec74ef06ef7562ee3f40527786ea3d6326146d1465a2927d6165b8/68747470733a2f2f7777772e636f6465666163746f722e696f2f7265706f7369746f72792f6769746875622f6a616765706172642f72756472612d726f757465722f6261646765)](https://www.codefactor.io/repository/github/jagepard/rudra-router)[![Coverage Status](https://camo.githubusercontent.com/53fda88a2824a3d573c61ee35de0631b58e184a264890f986763883bd6516e53/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f4a616765706172642f52756472612d526f757465722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/Jagepard/Rudra-Router?branch=master)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

[](#)

Rudra-Router
============

[](#rudra-router)

#### Basic installation / Базовая установка

[](#basic-installation--базовая-установка)

```
use Rudra\Router\Router;
use Rudra\Container\Rudra;

$router = new Router(Rudra::run());
```

#### Installation for facade use / Установка для использования фасада

[](#installation-for-facade-use--установка-для-использования-фасада)

```
use Rudra\Container\Facades\Rudra;
use Rudra\Router\RouterFacade as Router;
use Rudra\Container\Interfaces\RudraInterface;

Rudra::binding()->set([RudraInterface::class => Rudra::run()]);
```

#### Setting the route / Устанавливаем маршрут callback/:name

[](#setting-the-route--устанавливаем-маршрут-callbackname)

```
$router->get('callback/:name', function ($name) {
    echo "Hello $name!";
});
```

*with Regex*

```
$router->get('callback/:[\d]{1,3}', function ($name) {
    echo "Hello $name!";
});
```

*To call through the Facade / Для вызова через Фасад*

```
Router::get('callback/:name', function ($name) {
    echo "Hello $name!";
});
```

*with Regex*

```
Router::get('callback/:[\d]{1,3}', function ($name) {
    echo "Hello $name!";
});
```

*call / вызывает MainController::read*

```
$router->get('read/:id', [MainController::class, 'read']);
```

*To call through the Facade / Для вызова через Фасад*

```
Router::get('read/:id', [MainController::class, 'read']);
```

*call MainController::read with middleware*

```
$router->get('read/page',  [MainController::class, 'read'], ['before' => [Middleware::class]);
```

*To call through the Facade / Для вызова через Фасад*

```
Router::get('read/page',  [MainController::class, 'read'], ['before' => [Middleware::class]);
```

*С параметрами для middleware*

```
$router->get('', [MainController::class, 'read'], [
    'before' => [FirstMidddleware::class, [SecondMidddleware::class, ['int' => 456, new \stdClass]]],
    'after'  => [FirstMidddleware::class, [SecondMidddleware::class, ['int' => 456, new \stdClass]]]
]);
```

*call / вызывает MainController::create*

```
$router->post('create/:id', [MainController::class, 'create']);
```

*call / вызывает MainController::update*

```
$router->put('update/:id', [MainController::class, 'update']);
```

*call / вызывает MainController::update*

```
$router->patch('update/:id', [MainController::class, 'update']);
```

*call / вызывает MainController::delete*

```
$router->delete('delete/:id', [MainController::class, 'delete']);
```

*call / вызывает MainController::any 'GET|POST|PUT|PATCH|DELETE'*

```
$router->any('any/:id', [MainController::class, 'any']);
```

*call / вызывает MainController::read для GET*

*call / вызывает MainController::create для POST*

*call / вызывает MainController::update для PUT*

*call / вызывает MainController::delete для DELETE*

```
$router->resource('api/:id', MainController::class);
```

Изменить методы контроллера по умолчанию можно передав массив с вашими именами
You can change the default controller methods by passing an array with your names

```
$router->resource('api/:id', MainController::class, ['actionIndex', 'actionAdd', 'actionUpdate', 'actionDrop']);
```

#### A variant of declaring a route using the set method / Вариант объявления маршрута методом set

[](#a-variant-of-declaring-a-route-using-the-set-method--вариант-объявления-маршрута-методом-set)

*call / вызывает MainController::actionIndex*

```
$router->set(['/test/:id', 'DELETE|PUT', [MainController::class, 'actionIndex'], [
        'before' => [First::class, Second::class],
        'after'  => [[First::class], [Second::class]]
]]);
```

*Exemple / Пример Middleware*

```
/**
 * Handles requests as a middleware using __invoke().
 */
class SomeMiddleware
{
    public function __invoke($next, ...$params)
    {
        // Logic here

        if ($next) {
            $next();
        }
    }
}
```

License
-------

[](#license)

This project is licensed under the **Mozilla Public License 2.0 (MPL-2.0)** — a free, open-source license that:

- Requires preservation of copyright and license notices,
- Allows commercial and non-commercial use,
- Requires that any modifications to the original files remain open under MPL-2.0,
- Permits combining with proprietary code in larger works.

📄 Full license text: [LICENSE](./LICENSE)
🌐 Official MPL-2.0 page:

---

Проект распространяется под лицензией **Mozilla Public License 2.0 (MPL-2.0)**. Это означает:

- Вы можете свободно использовать, изменять и распространять код.
- При изменении файлов, содержащих исходный код из этого репозитория, вы обязаны оставить их открытыми под той же лицензией.
- Вы **обязаны сохранять уведомления об авторстве** и ссылку на оригинал.
- Вы можете встраивать код в проприетарные проекты, если исходные файлы остаются под MPL.

📄 Полный текст лицензии (на английском): [LICENSE](./LICENSE)
🌐 Официальная страница:

###  Health Score

48

—

FairBetter than 94% of packages

Maintenance92

Actively maintained with recent releases

Popularity19

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 99.7% 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 ~82 days

Total

5

Last Release

40d ago

Major Versions

v25.6 → v26.12026-05-21

### Community

Maintainers

![](https://www.gravatar.com/avatar/75e65761bdd94035d1c783773a706d5722ce3164fe55d9722581c2cb4a642d8c?d=identicon)[jagepard](/maintainers/jagepard)

---

Top Contributors

[![Jagepard](https://avatars.githubusercontent.com/u/4591345?v=4)](https://github.com/Jagepard "Jagepard (602 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (2 commits)")

---

Tags

middlewarerestrest-routerrestfulrouterroutingrudrarestrouterroutingREST routerrestfulrudra

### Embed Badge

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

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

###  Alternatives

[aplus/routing

Aplus Framework Routing Library

2551.6M3](/packages/aplus-routing)[contributte/api-router

RESTful Router for your Apis in Nette Framework - created either directly or via attributes

20809.0k3](/packages/contributte-api-router)

PHPackages © 2026

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