PHPackages                             primate/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. primate/router

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

primate/router
==============

Primitive router

04PHP

Since May 2Pushed 2y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

[![PHPunit](https://github.com/Jagepard/Primate-Router/actions/workflows/php.yml/badge.svg)](https://github.com/Jagepard/Primate-Router/actions/workflows/php.yml)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/6736ba784181dc13e3f82803d2fc45465f994531ae1bc2d330bf362be4041ab8/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4a616765706172642f5072696d6174652d526f757465722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Jagepard/Primate-Router/?branch=master)[![Maintainability](https://camo.githubusercontent.com/ced111b349e781a6f09a6170a26b667d9786452256a6ff9794bf709042d4be7c/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f66633063613233613466353565366564323634662f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/Jagepard/Primate-Router/maintainability)[![License: MIT](https://camo.githubusercontent.com/3e0868d609f94ce684fbe70282b38fcae81a66ada50e174da17a8b9ccc0ebbe7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d3439386537662e737667)](https://mit-license.org/)

Primate-Router
==============

[](#primate-router)

### Прмиитивный маршрутизатор, для упрощения понимания логики. | [API](https://github.com/Jagepard/Primate-Router/blob/master/api.md "Documentation API")

[](#прмиитивный-маршрутизатор-для-упрощения-понимания-логики--api)

Использование:

```
use Primate\Router\Router;

$router = new Router();
```

Далее обязательно разбираем "REQUEST\_URI"

```
$requestUri = explode('/', trim(parse_url($_SERVER["REQUEST_URI"])["path"], '/'));
```

После добавления всех маршрутов вызываем метод сопоставление маршрутов с данными запроса "REQUEST\_URI"

```
$router->matchRoute($requestUri);
```

Добавление маршрутов:
---------------------

[](#добавление-маршрутов)

В случае перехода по адресу /closure в браузере, в окне будет отображено "Hello World!", по умолчанию $\_SERVER\["REQUEST\_METHOD"\] === "GET"

```
$router->addRoute("/closure", function () {
    echo "Hello World!";
});
```

В случае перехода по адресу /closure/john в браузере, в окне будет отображено "Hello john!"

```
$router->addRoute("/closure/:name", function ($name) {
    echo "Hello $name!";
});
```

При изменении метода запроса необходимо также его указать 3 параметром при добавлении маршрута

```
$router->addRoute("/closure", function () {
    echo "Hello World!";
}, "POST");
```

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity19

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/75e65761bdd94035d1c783773a706d5722ce3164fe55d9722581c2cb4a642d8c?d=identicon)[jagepard](/maintainers/jagepard)

---

Top Contributors

[![Jagepard](https://avatars.githubusercontent.com/u/4591345?v=4)](https://github.com/Jagepard "Jagepard (28 commits)")

### Embed Badge

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

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

PHPackages © 2026

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