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

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

ceus-media/router
=================

0.6.1(1y ago)05141GPL-3.0+PHPPHP ^8.3

Since Oct 11Pushed 1y ago1 watchersCompare

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

READMEChangelog (8)Dependencies (7)Versions (15)Used By (1)

Router
======

[](#router)

[![Branch](https://camo.githubusercontent.com/111907174dbee71200e92e00dcb89b58c1d41e9c115bea532c470c0794492fea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4272616e63682d302e352e782d626c75653f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/111907174dbee71200e92e00dcb89b58c1d41e9c115bea532c470c0794492fea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4272616e63682d302e352e782d626c75653f7374796c653d666c61742d737175617265)[![Release](https://camo.githubusercontent.com/b03ac8dd3a601d2181d1e5f6667aa1c323f8b04468d5daa3c09bd65ba39db871/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f52656c656173652d302e352e312d626c75653f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/b03ac8dd3a601d2181d1e5f6667aa1c323f8b04468d5daa3c09bd65ba39db871/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f52656c656173652d302e352e312d626c75653f7374796c653d666c61742d737175617265)[![PHP version](https://camo.githubusercontent.com/7ebb0279547d526a54d318d9ab47d214fc6a36936050d77b00e120c3ce9db3f1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253545382e312d626c75653f7374796c653d666c61742d73717561726526636f6c6f723d373737424234)](https://camo.githubusercontent.com/7ebb0279547d526a54d318d9ab47d214fc6a36936050d77b00e120c3ce9db3f1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253545382e312d626c75653f7374796c653d666c61742d73717561726526636f6c6f723d373737424234)[![PHPStan level](https://camo.githubusercontent.com/9984e4473ea56a498868ac5a3ffe61ded3a318f72f3deac309709cd1324b9263/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e5f6c6576656c2d6d61782b7374726963742d6461726b677265656e3f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/9984e4473ea56a498868ac5a3ffe61ded3a318f72f3deac309709cd1324b9263/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e5f6c6576656c2d6d61782b7374726963742d6461726b677265656e3f7374796c653d666c61742d737175617265)

PHP router for HTTP requests.
Branch for PHP 8 support.

Examples
--------

[](#examples)

### Simplest: single JSON file

[](#simplest-single-json-file)

Route map as JSON file:

```
[
    {
        "controller": "Controller_Test",
        "action": "test",
        "pattern": "test :a (:b)",
        "method": "CLI"
    },
    {
        "controller": "Controller_Test",
        "action": "test",
        "pattern": "\/test\/:a\/(:b)",
        "method": "GET"
    }
]

```

As you can see, the router works for CLI and HTTP environments.

Controller class:

```
class Controller_Test
{
	public function test( string $a = NULL, ?string $b = NULL ): string
	{
		return 'Called: Controller_Test::test($a, $b)' );
	}
}

```

Router setup:

```
use CeusMedia\Router;

$source		= Router\Registry\Source\JsonFile::create()->setResource( 'test.json' );
$registry	= Router\Registry::create()->addSource( $source );
$router		= Router\Router::create()->setRegistry( $registry );

```

Resolving a route:

```
$path	= 'test a1 b2';
$route	= $router->resolve( $path );

```

You could execute the resolved route controller action like this:

```
$result	= \CeusMedia\Common\Alg\Obj\MethodFactory::staticCallClassMethod(
	$route->getController(),
	$route->getAction(),
	[],
	$route->getArguments()
);

```

### Using multiple JSON files in a folder

[](#using-multiple-json-files-in-a-folder)

```
$source	= Router\Registry\Source\JsonFolder::create()->setResource( 'routes/' );

```

#### Using a cache on top

[](#using-a-cache-on-top)

Invalidate cache if routes file has changed:

```
$invalidateCache = FALSE;
if( $invalidateCache ){
	$memcache = new Memcache();
	$memcache->connect( 'localhost', 11211 );
	$memcache->delete( 'CeusMediaRouterCliDemo1' );
}

```

Setup, related to cache invalidation request:

```
$sourceMemcache	= new Router\Registry\Source\Memcache( 'localhost:11211:CeusMediaRouterCliDemo1' );
$sourceMemcache->setOption( Router\Registry\SourceInterface::OPTION_AUTOSAVE, TRUE );
$sourceMemcache->setOption( Router\Registry\SourceInterface::OPTION_AUTOLOAD, !$invalidateCache );

...

$registry->addSource( $sourceMemcache );
$registry->addSource( $sourceJsonFile );

```

###  Health Score

41

—

FairBetter than 88% of packages

Maintenance50

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 87.4% 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 ~239 days

Recently: every ~7 days

Total

14

Last Release

392d ago

PHP version history (4 changes)0.1PHP &gt;=5.3.0

0.4PHP &gt;=7.4

0.5PHP ^8.1

0.6.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/fafb923e05a0e4cdd0cd6a6093f3452ce75aab95949121e7ab180686343dce14?d=identicon)[kriss0r](/maintainers/kriss0r)

---

Top Contributors

[![kriss0r](https://avatars.githubusercontent.com/u/476914?v=4)](https://github.com/kriss0r "kriss0r (76 commits)")[![cwuerker-c24](https://avatars.githubusercontent.com/u/155151774?v=4)](https://github.com/cwuerker-c24 "cwuerker-c24 (11 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[t3docs/examples

This extension packages a number of code examples from the Core Documentation.

3120.2k](/packages/t3docs-examples)

PHPackages © 2026

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