PHPackages                             vitodtagliente/pure-routing - 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. vitodtagliente/pure-routing

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

vitodtagliente/pure-routing
===========================

The Pure Routing Component

v1.0.0(3y ago)48211MITPHP

Since Jan 13Pushed 3y ago1 watchersCompare

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

READMEChangelog (1)DependenciesVersions (2)Used By (1)

Pure Routing Component
======================

[](#pure-routing-component)

The Routing component maps an HTTP request to a set of configuration variables.

HOW TO
======

[](#how-to)

1. Instantiate the router

    ```
    $router = new Pure/Routing/Router();
    ```
2. define the routes

    ```
    $router->get('/foo', $callback);    // GET method
    $router->post('/foo', $callback);   // POST method
    $router->put('/foo', $callback);    // PUT method
    $router->delete('/foo', $callback); // DELETE method
    ```

    $callback can be:

    - a function:

        ```
        $router->get('/foo', function(){ ... });
        ```
    - a string:

        ```
        function foo(){ ... }
        $router->get('/foo', 'foo');
        ```

        where **foo** is a function.

        Besides, the callback can be a controller.

        ```
        $router->get('/foo', 'FooController@action');
        ```

        Remember that all the namespace closures must be defined, like in the example:

        ```
        $router->get('/foo', 'App\Controllers\FooController@action');

        $router->get('/foo', 'App\Controllers\FooController::class . '@action');
        ```

        Is it possible to define namespace alias, like in this example:

        ```
        $router->namespace('app', 'App\Controllers');
        $router->get('/foo', 'app::FooController@action');
        ```
3. Defining routes with parameters

    - Parameters can be defined using (\*\*$\*\*variable) syntax, like in php ```
        $routes->get('/user/$username', function($username){} );
        ```
    - Parameters can be associated with regular expression There are 3 types of default regular expression
        - i: integer
        - a: alphanumeric
        - c: characters In this example we define $id as an integer:

        ```
        $router->get('/user/$id:i', function($id){ ... } );
        ```

        It is possible to add new regular expression: ```
        $router->rule('k', 'regular_expression');
        ```

How To define middlewares
-------------------------

[](#how-to-define-middlewares)

Middlewares let to check a route before executing it. Let's take an example, try to protect the 'dashboard' navigation from users that are not logged in:

```
use Pure\Routing\Middleware;

class AuthMiddleware extends Middleware
{
    public function handle(){
        // returns true if the user is logged in
        return MyAuthNamespace\Auth::check();
    }
}
```

```
$router->get('/dashboard', $callback)->middleware(AuthMiddleware::class);
```

If the handle function returns false, the route execution is stopped.

###  Health Score

25

—

LowBetter than 36% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88% 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

Unknown

Total

1

Last Release

1264d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/61137c8fad7251ed9bcd84692d5ef8153dc8de8c6a09d182b9a1d69854d2a0b2?d=identicon)[vitodtagliente](/maintainers/vitodtagliente)

---

Top Contributors

[![vitodtagliente](https://avatars.githubusercontent.com/u/5153783?v=4)](https://github.com/vitodtagliente "vitodtagliente (22 commits)")[![irpcpro](https://avatars.githubusercontent.com/u/35578127?v=4)](https://github.com/irpcpro "irpcpro (2 commits)")[![yaonkey](https://avatars.githubusercontent.com/u/9325217?v=4)](https://github.com/yaonkey "yaonkey (1 commits)")

### Embed Badge

![Health badge](/badges/vitodtagliente-pure-routing/health.svg)

```
[![Health](https://phpackages.com/badges/vitodtagliente-pure-routing/health.svg)](https://phpackages.com/packages/vitodtagliente-pure-routing)
```

###  Alternatives

[firegento/magesetup2

MageSetup provides the necessary configuration (system config, tax, agreements, etc. for a national market.

121340.5k1](/packages/firegento-magesetup2)[sixlive/nova-text-copy-field

Laravel Nova text field with click to copy support

69717.8k2](/packages/sixlive-nova-text-copy-field)[thelia/currency-converter

php 5.4 currency tools

1099.7k2](/packages/thelia-currency-converter)[oveleon/contao-recommendation-bundle

Recommendation integration for Contao Open Source CMS

107.7k2](/packages/oveleon-contao-recommendation-bundle)

PHPackages © 2026

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