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

ActiveLibrary[Framework](/categories/framework)

sasa-b/router
=============

Lightweight and performant router inspired by laravel's, and phalcon's router.

1.0.2(8y ago)125MITPHP

Since Oct 7Pushed 8y ago1 watchersCompare

[ Source](https://github.com/sasa-b/router)[ Packagist](https://packagist.org/packages/sasa-b/router)[ Docs](https://sasablagojevic.com)[ RSS](/packages/sasa-b-router/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

Router
======

[](#router)

Lightweight router inspired by Laravel's and Phalcon's router.

---

Usage examples
--------------

[](#usage-examples)

```
$router = new \Foundation\Routing\Router();

$r->get('/foo', function () {
    echo 'Hello foo!';
});

// here we are utilising cache for performance, if the cache file was not found
// routes will be registered and the cache file recreated
$router->cache(function (\Foundation\Routing\Router $r) {
    // if you want to collect routes from a file
    // you can set the path to the routes file as a paramater to collectRoutes() method
    // or via setRoutesPath() method
    $r->collectRoutes();

    // you can both collect routes and add them one by one, they will be merged
    $r->get('/foo/{bar}', [
        'controller' => 'FooController',
        'action' => 'index',
    ]);

    $r->post('/foo/{bar}', 'FooController::store');
});

try {
    // Adding event listeners
    $router->addEventListener('before_match', function(\Foundation\Routing\Router $router) {
        echo "before match";
    });

    $router->addEventListener('after_match', function(\Foundation\Routing\Router $router) {
        echo "after match";
    });

    $dispatcher = $router->catch();

    $dispatcher->dispatch();

} catch (\Foundation\Routing\Exceptions\NotFoundException $e) {
    echo $e->getCode() . " - Page not found";
} catch (\Foundation\Routing\Exceptions\BadHttpMethodException $e) {
    echo $e->getCode() . " - Bad Http Method";
}
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity65

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

Total

3

Last Release

3134d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b69f1d9205d4b96ec1c90ff7bc2503f1d14ea4b0b89b82b406c16f922c634133?d=identicon)[sasa-b](/maintainers/sasa-b)

---

Top Contributors

[![sasa-b](https://avatars.githubusercontent.com/u/18427949?v=4)](https://github.com/sasa-b "sasa-b (12 commits)")

---

Tags

dispatcherlibraryphprouterrouterroutingdispatcher

### Embed Badge

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

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

###  Alternatives

[klein/klein

A lightning fast router for PHP

2.7k1.1M30](/packages/klein-klein)[pecee/simple-router

Simple, fast PHP router that is easy to get integrated and in almost any project. Heavily inspired by the Laravel router.

696214.6k17](/packages/pecee-simple-router)[vlucas/bulletphp

A heierarchical resource-oriented micro-framework built on nested closures instead of route-based callbacks

41949.9k1](/packages/vlucas-bulletphp)[izniburak/router

simple router class for php

23522.6k7](/packages/izniburak-router)[vectorface/snappy-router

A quick and snappy routing framework.

4614.7k](/packages/vectorface-snappy-router)[thewunder/croute

Convention based routing for PHP

1317.4k](/packages/thewunder-croute)

PHPackages © 2026

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