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

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

pinga/router
============

Router for PHP. Simple, lightweight and convenient.

v0.1(3y ago)181MITPHPPHP &gt;=8.1.0

Since Jan 27Pushed 3y agoCompare

[ Source](https://github.com/getpinga/router)[ Packagist](https://packagist.org/packages/pinga/router)[ Docs](https://github.com/delight-im/PHP-Router)[ RSS](/packages/pinga-router/feed)WikiDiscussions master Synced 1mo ago

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

Pinga Router
============

[](#pinga-router)

Router for PHP. Simple, lightweight and convenient.

Requirements
------------

[](#requirements)

- PHP 8.1.0+

Installation
------------

[](#installation)

1. Include the library via Composer [\[?\]](https://github.com/delight-im/Knowledge/blob/master/Composer%20(PHP).md):

    ```
    $ composer require pinga/router

    ```
2. Include the Composer autoloader:

    ```
    require __DIR__ . '/vendor/autoload.php';
    ```

Usage
-----

[](#usage)

1. Enable URL rewriting on your web server

    - Apache (in `.htaccess` or `httpd.conf`)

        ```
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule . index.php [L]

        ```
    - Nginx (in `nginx.conf`)

        ```
        try_files $uri /index.php;

        ```
2. Create a new `Router` instance

    - for the web root

        ```
        $router = new \Delight\Router\Router();
        ```
    - for any subdirectory

        ```
        $router = new \Delight\Router\Router('/my/base/path');
        ```
3. Add some routes and map them to anonymous functions or closures

    - Static route:

        ```
        $router->get('/', function () {
            // do something
        });
        ```
    - Dynamic route (with parameters):

        ```
        $router->get('/users/:id/photo', function ($id) {
            // get the photo for user `$id`
        });
        ```

        The values of parameters matched in the URL can be captured as arguments in the callback.
    - Route with multiple supported request methods:

        ```
        $router->any([ 'POST', 'PUT' ], '/users/:id/address', function ($id) {
            // update the address for user `$id`
        });
        ```
4. Map routes to controller methods instead for more complex callbacks

    ```
    // use static methods
    $router->get('/photos/:id/convert/:mode', [ 'PhotoController', 'myStaticMethod' ]);

    // or

    // instance methods
    $router->get('/photos/:id/convert/:mode', [ $myPhotoController, 'myInstanceMethod' ]);
    ```
5. Inject arguments for access to further values and objects (prepended to those matched in the route)

    ```
    class MyController {

        public static function someStaticMethod($database, $uuid) {
            // do something
        }

    }
    ```

    and

    ```
    $database = new MyDatabase();

    // ...

    $router->delete('/messages/:uuid', [ 'MyController', 'someStaticMethod' ], [ $database ]);
    ```

Contributing
------------

[](#contributing)

All contributions are welcome! If you wish to contribute, please create an issue first so that your feature, problem or question can be discussed.

License
-------

[](#license)

This project is licensed under the terms of the [MIT License](https://opensource.org/licenses/MIT).

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

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

1198d ago

### Community

Maintainers

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

---

Top Contributors

[![ocram](https://avatars.githubusercontent.com/u/1681478?v=4)](https://github.com/ocram "ocram (61 commits)")[![getpinga](https://avatars.githubusercontent.com/u/121483313?v=4)](https://github.com/getpinga "getpinga (9 commits)")

---

Tags

httprouterroutingroute

### Embed Badge

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

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

###  Alternatives

[aura/router

Powerful, flexible web routing for PSR-7 requests.

5231.5M67](/packages/aura-router)[miladrahimi/phprouter

A powerful, lightweight, and very fast HTTP URL router for PHP projects.

20832.6k2](/packages/miladrahimi-phprouter)[pmjones/auto-route

Automatically routes HTTP request to action classes.

20158.6k6](/packages/pmjones-auto-route)[contributte/api-router

RESTful Router for your Apis in Nette Framework - created either directly or via attributes

20802.8k3](/packages/contributte-api-router)[delight-im/router

Router for PHP. Simple, lightweight and convenient.

432.3k1](/packages/delight-im-router)[wilaak/radix-router

High-performance radix tree based HTTP request router

612.8k5](/packages/wilaak-radix-router)

PHPackages © 2026

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