PHPackages                             elzekool/koolrouter - 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. elzekool/koolrouter

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

elzekool/koolrouter
===================

Fast and flexible PHP5.3+ router with RESTfull support and reverse routing.

0.2.0(12y ago)023MITPHPPHP &gt;=5.3.0

Since Jul 14Pushed 12y agoCompare

[ Source](https://github.com/elzekool/KoolRouter)[ Packagist](https://packagist.org/packages/elzekool/koolrouter)[ Docs](https://github.com/elzekool/KoolRouter)[ RSS](/packages/elzekool-koolrouter/feed)WikiDiscussions master Synced 2mo ago

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

KoolRouter
==========

[](#koolrouter)

KoolRouter is a fast, easy to integrate Router. It's inspired by by [klein.php](https://github.com/chriso/klein.php/)and \[AltoRouter\] ().

It should me used in conjunction with a dispatcher and HTTP interface, as it does (by purpose) not provides these features.

Key features
------------

[](#key-features)

- Routing URL's to callback functions
- Reverse routing a route and parameters to the corresponding path
- Simple routing syntax

Starting with KoolRouter
------------------------

[](#starting-with-koolrouter)

1. Make sure PHP 5.3.\* is installed
2. Install KoolRouter using [Composer](https://github.com/elzekool/KoolRouter#composer) or manually
3. Make KoolRouter handle your requests (for example trough URL Rewriting)

Supported Routes
----------------

[](#supported-routes)

You can use the following syntax within your routes.

```
    *                    // Match all request URIs
    [i]                  // Match an integer
    [i:id]               // Match an integer as 'id'
    [a:action]           // Match alphanumeric characters as 'action'
    [h:key]              // Match hexadecimal characters as 'key'
    [:action]            // Match anything up to the next / or end of the URI as 'action'
    [create|edit:action] // Match either 'create' or 'edit' as 'action'
    [*]                  // Catch all (lazy, stops at the next trailing slash)
    [*:trailing]         // Catch all as 'trailing' (lazy)
    [**:trailing]        // Catch all (possessive - will match the rest of the URI)
    .[:format]?          // Match an optional parameter 'format' - a / or . before the block is also optional

Some examples

    /pages[/index]?            // Matches "/pages" and "/pages/index"
    /posts/[*:title][i:id]     // Matches "/posts/this-is-a-title-123"
    /output.[xml|json:format]? // Matches "/output", "output.xml", "output.json"
    /[:controller]?/[:action]? // Matches the typical /controller/action format

```

Example
-------

[](#example)

```
use ElzeKool\KoolRouter\Router;

$router = new Router();

// Setup route
$router->map(
    'GET /pages/[i:id]',
    function($method, $path, $parameters, $extra) {
        echo 'Hello i\'m page ' . $parameters['id'];
    },
    'page_view'
);

// Start routing
$router->run();

// Reverse routing
// (returns: /pages/10)
$route = $router->reverse('page_view', array(
    'id' => 10
));
```

Composer
--------

[](#composer)

- Get [Composer](http://getcomposer.org/)
- Add `elzekool/koolrouter` to your `composer.json` file:

```
{
    "require": {
        "elzekool/koolrouter": "0.*"
    }
}
```

- Install/update your dependencies with: `php composer.phar install`

License
-------

[](#license)

(MIT License)

Copyright (c) 2013 Elze Kool

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

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

Total

2

Last Release

4682d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/90e8d05eab1cd42d9ae3ab39d812ccc24eb617935e9ce968ec36f9b8da2eedb8?d=identicon)[elzekool](/maintainers/elzekool)

---

Tags

restrouterlibraryrouting

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/elzekool-koolrouter/health.svg)

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

###  Alternatives

[aplus/routing

Aplus Framework Routing Library

2491.6M3](/packages/aplus-routing)[contributte/api-router

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

20802.8k3](/packages/contributte-api-router)

PHPackages © 2026

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