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

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

infrajs/router
==============

Router for Infrajs

v1.1.20(5y ago)02.7k[1 issues](https://github.com/infrajs/router/issues)20PHP

Since Apr 10Pushed 5y ago1 watchersCompare

[ Source](https://github.com/infrajs/router)[ Packagist](https://packagist.org/packages/infrajs/router)[ Docs](https://github.com/infrajs/router)[ RSS](/packages/infrajs-router/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (7)Dependencies (8)Versions (23)Used By (20)

Роутер Infrajs
==============

[](#роутер-infrajs)

Включает:

- Работа коротких адресов с символами **-~!** для сторонних вендоров - [infrajs/config-search](https://github.com/infrajs/config-search)
- Автоматическую инсталяцию расширений - [infrajs/update](https://github.com/infrajs/update)
- Конфиг .infra.json расширений автоматически загружается и выполняется при обращени к любому классу расширения - [infrajs/config](https://github.com/infrajs/config)
- простейшие уровни доступа test debug admin - [infrajs/access](https://github.com/infrajs/access)
- HTTP-заголовки по умолчанию от расширений - [infrajs/nostore](https://github.com/infrajs/nostore), [infrajs/access](https://github.com/infrajs/access)
- контроллер слоёв index.json - [infrajs/controller](https://github.com/infrajs/controller)

Использовние
------------

[](#использовние)

Рабочей папкой php скриптов должен быть корень проекта. Это важное требование для совместимости [infrajs/path](https://github.com/infrajs/path). Изменить рабочую папку очень просто с помощью станадртной php функции [chdir](http://php.net/manual/function.chdir.php)

```
use infrajs\router\Router;
use infrajs\path\Path;
if (!is_file('vendor/autoload.php')) {
	chdir('../../../'); //Путь до корня проекта с папкой vendor/
	require_once('vendor/autoload.php');
	Router::init();
}
$src = Path::theme('-plugin/test.php'); //vendor/name/plugin/test.php
```

Если настроен .htaccess

```
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ vendor/infrajs/router/index.php [L,QSA]

```

Сокращения будут работать в адресной строке **-test/test.php**. из скрипта можно убрать `Router::init()`, `chdir()` и `vendor/autoload.php`, они уже будут выполнены в `vendor/infrajs/router/index.php`, указанному в `.htaccess`.

```
use infrajs\path\Path;

$src = Path::theme('-test/test.php'); //vendor/test/test.php
```

Инициализация роутера в скрипте
-------------------------------

[](#инициализация-роутера-в-скрипте)

Для независимой работы расширения можно оставлять возможность прямого обращения к нему, без сокращений **-**, тогда в код нужно добавить вызов '''Router::init();'''. Это требуется для инициализации и выполнения конфигов ([.infra.json](https://github.com/infrajs/config)) самого расширения и его зависимостей.

```
if (!is_file('vendor/autoload.php')) {
	chdir('../../../');
	require_once('vendor/autoload.php');
	Router::init();
}
```

или самый универальный вариант

```
if (!is_file('vendor/autoload.php')) chdir('../');
require_once('vendor/autoload.php');
Router::init();
```

Перенаправить запросы на свой php файлы
---------------------------------------

[](#перенаправить-запросы-на-свой-php-файлы)

С точки зрения роутера все запросы, для которых не найдено файла, являются 404 ошибкой. По этому нужно определить 404 страницу, как php файл, на который и будут приходить все запросы. Нужно создать файл **.infra.json** в корне проекта.

```
{
	"router":{
		"404":"index.php"
	}
}
```

.htaccess только для сокращённых адресов
----------------------------------------

[](#htaccess-только-для-сокращённых-адресов)

```
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/[-~\!]
RewriteRule ^(.*)$ vendor/infrajs/router/index.php [L,QSA]

```

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity73

Established project with proven stability

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

Recently: every ~217 days

Total

22

Last Release

2149d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/341a8ef8a06866ad99b1bbcf0216fd8e331b076b1690a7d992c386192674b787?d=identicon)[akiyatkin](/maintainers/akiyatkin)

---

Top Contributors

[![akiyatkin](https://avatars.githubusercontent.com/u/953753?v=4)](https://github.com/akiyatkin "akiyatkin (37 commits)")

### Embed Badge

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

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

PHPackages © 2026

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