PHPackages                             istok/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. [Framework](/categories/framework)
4. /
5. istok/router

ActiveLibrary[Framework](/categories/framework)

istok/router
============

Basic routing component

0.0.3(4y ago)07MITPHPPHP ^8.1

Since May 1Pushed 4y ago1 watchersCompare

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

READMEChangelogDependencies (2)Versions (4)Used By (0)

```
composer require istok/router
```

Basic router
============

[](#basic-router)

- matching given `Request` (essentially `array`) to `mixed $handler`
- comes with implementation suitable for http request
- Support variables, like `/post/{id}/`
- build to play with `istok/container`
- (I hope) it can be easily extended to route something else than `http` (console, queue)

Usage (currently no sugar provided)
-----------------------------------

[](#usage-currently-no-sugar-provided)

Working example in `example.com`, don't forget to install dependencies first.

```
use Istok\Router\Router;
use Istok\Router\Route;
use Istok\Router\Http\HttpTemplate;
use Istok\Router\Http\HttpRequest;

// define single router entry
$route = new Route(
    // provide template interface
    new HttpTemplate('/post/{id}/show', 'GET', '{user}.example.com'),
    // provide handler
    fn($id, $user) => print "User: $user, id: $id"
);

// setup router, add our single route
$router = new Router($route);

// special http-oriented implementation of Request interface
$request = new HttpRequest('/post/abc/show', 'GET', 'user1.example.com');

// match route to request
$result = $router->find($request);

// execute result,
// $result->arguments contains ['user' => 'user1', 'id' => 'abc']
($result->route->handler)(...$result->arguments); // User: user1, id: abc
```

How to capture rest part of template
------------------------------------

[](#how-to-capture-rest-part-of-template)

Last one in `path`

```
$template =  new HttpTemplate('/post/{url*}'),
```

will match `/post/abc/def`, with arguments `['url' => 'abc/def']`

Similar in `host`

```
$template =  new HttpTemplate('/', host: '{subdomain*}.example.com'),
```

will match `abc.def.example.com`, with arguments `['subdomain' => 'abc.def']`

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

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

Total

3

Last Release

1519d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/62257854467f165e1ec97a01abf9999a603eca22a0345e9af7d33c1cf7413975?d=identicon)[the-toster](/maintainers/the-toster)

---

Top Contributors

[![the-toster](https://avatars.githubusercontent.com/u/22966096?v=4)](https://github.com/the-toster "the-toster (6 commits)")

### Embed Badge

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

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

###  Alternatives

[pestphp/pest

The elegant PHP Testing Framework.

11.6k72.2M20.6k](/packages/pestphp-pest)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[laravel/browser-kit-testing

Provides backwards compatibility for BrowserKit testing in the latest Laravel release.

51710.0M303](/packages/laravel-browser-kit-testing)[contao/contao

Contao Open Source CMS development package

43114.4k2](/packages/contao-contao)[drupal/core-dev

require-dev dependencies from drupal/drupal; use in addition to drupal/core-recommended to run tests from drupal/core.

2022.6M343](/packages/drupal-core-dev)[mage2pro/core

Mage2.PRO core package.

1141.4k129](/packages/mage2pro-core)

PHPackages © 2026

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