PHPackages                             touskar/sen-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. [HTTP &amp; Networking](/categories/http)
4. /
5. touskar/sen-router

ActiveLibrary[HTTP &amp; Networking](/categories/http)

touskar/sen-router
==================

Fast router for php with regex, middleware route separator support

05PHP

Since Feb 3Pushed 8y ago1 watchersCompare

[ Source](https://github.com/touskar/sen-router)[ Packagist](https://packagist.org/packages/touskar/sen-router)[ RSS](/packages/touskar-sen-router/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

```

 _________                       __________               __
 /   _____/ ____   ____           \______   \ ____  __ ___/  |_  ___________
 \_____  \_/ __ \ /    \   ______  |       _//  _ \|  |  \   __\/ __ \_  __ \
 /        \  ___/|   |  \ /_____/  |    |   (   )  |  /|  | \  ___/|  | \/
/_______  /\___  >___|  /          |____|_  /\____/|____/ |__|  \___  >__|
        \/     \/     \/                  \/                        \/
------------------------------------------------------------------------------

```

Info
====

[](#info)

[Click to see SenRouter in Packagist](https://packagist.org/packages/touskar/sen-router)

Install
=======

[](#install)

composer require touskar/sen-router

Usage
=====

[](#usage)

#### .htacess for frontal controller

[](#htacess-for-frontal-controller)

```
SetEnv FRONTAL_CONTROLER index.php
SetEnv FRONTAL_CONTROLER_SUB_DIR /web/root/ # or / for non subdired project

    Options -MultiViews
    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule . %{ENV:FRONTAL_CONTROLER} [L]

    RewriteCond %{HTTP:Authorization} ^(.*)
    RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]

```

#### index.php

[](#indexphp)

```
require_once('../vendor/autoload.php');

use SenRouter\Http\Dispatcher\Router;
use SenRouter\Http\Dispatcher\R;

$router = new Router();

/**
 * call from $router Object
 **/
$router
    ->get('hello/{name}', function ($name) {
        return "Hello $name";
    });

/**
 * call from static method
 **/
R::('hello.{name}', function ($name) {
        return "Hello $name";
    })
    ->separator(".");

/**
 * Call from static method
 * mixte route params and query params
 * https://example.com/user/moussa_ndour@hotmail.fr/bicis?order_by=name
 */
R::get('users/{email}/{entreprise}', function ($email, $entreprise) {
    $orderBy = Input::one('order_by');
    return "Hello $email $entreprise with query $orderBy";
});

/**
 * Call from static method
 **/
R::get('calcul.{num1}.{num2}', function ($num1, $num2) {
    return Response::withJson([
        'result' => $num1 + $num2
    ]);
})
    ->regex([
        'num1' => '\d+',
        'num2' => '\d+'
    ])
    ->middleware([
        'HomeMiddleware@isOdd',
        function ($num1, $num2) {
            if ($num1 == $num2) {
                return false;
            }
        }
    ])
    ->separator(".");

$router->run();
//or
R::run();
```

#### HomeController

[](#homecontroller)

```
use SenRouter\Http\Response;
class HomeController{

    public function sum($num1, $num2){
        return Response::withJson([
            'result' => $num1 + $num2
        ]);
    }
}
```

#### HomeMiddleware

[](#homemiddleware)

```
use SenRouter\Http\Response;
class HomeMiddleware{

     /**
      * Return strict value False or no empty string to block
      * returned value will be send as request response
      */
    public function isOdd($num1, $num2){
        if($num1 % 2 !== 0 || $num2 % 2 !== 0 )
        {
            return false;// return 'some_string';
        }
    }
}
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 89.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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/13134736?v=4)[Moussa Ndour DSI at INTech Group | Innolink](/maintainers/Touskar)[@touskar](https://github.com/touskar)

---

Top Contributors

[![touskar](https://avatars.githubusercontent.com/u/13134736?v=4)](https://github.com/touskar "touskar (42 commits)")[![droussDotOrg](https://avatars.githubusercontent.com/u/14190308?v=4)](https://github.com/droussDotOrg "droussDotOrg (5 commits)")

### Embed Badge

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

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

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M319](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[nyholm/psr7

A fast PHP7 implementation of PSR-7

1.3k235.4M2.4k](/packages/nyholm-psr7)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M293](/packages/pusher-pusher-php-server)[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78126.4M414](/packages/react-http)

PHPackages © 2026

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