PHPackages                             penobit/irouter - 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. penobit/irouter

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

penobit/irouter
===============

A lightning fast router for PHP

v1.1(4y ago)14MITPHPPHP &gt;=5.6.0

Since Jun 2Pushed 4y ago1 watchersCompare

[ Source](https://github.com/penobit/iRouter)[ Packagist](https://packagist.org/packages/penobit/irouter)[ Docs](https://github.com/dannyvankooten/AltoRouter)[ RSS](/packages/penobit-irouter/feed)WikiDiscussions main Synced 1w ago

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

iRouter
=======

[](#irouter)

[![Build Status](https://camo.githubusercontent.com/345416a70fe29b76dabc91a2ddf96205f49f3533ce726c2c6043560724007294/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f70656e6f6269742f69526f757465722f6d6173746572)](https://travis-ci.org/penobit/iRouter) [![Latest Stable Version](https://camo.githubusercontent.com/c723510a781316fb54d05b19debfe40dc3105d35fb827707a34b1367e4c05955/68747470733a2f2f706f7365722e707567782e6f72672f70656e6f6269742f69726f757465722f762f737461626c652e737667)](https://packagist.org/packages/penobit/irouter) [![License](https://camo.githubusercontent.com/71f94e2d28aff9539a16f63facfc82573a55587e687e3515118f520aebc5901a/68747470733a2f2f706f7365722e707567782e6f72672f70656e6f6269742f69726f757465722f6c6963656e73652e737667)](https://packagist.org/packages/penobit/irouter)

- [iRouter](#irouter)
    - [Installation](#installation)
    - [Requirements](#requirements)
    - [Features](#features)
    - [Examples](#examples)
        - [Adding a route](#adding-a-route)
        - [Adding multiple routes at once](#adding-multiple-routes-at-once)
        - [Dynamic routes (with parameters)](#dynamic-routes-with-parameters)
        - [Match types](#match-types)
            - [adding a match type](#adding-match-types)
            - [Default match types](#default-match-types)

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

[](#installation)

You can install this package using composer or download last release from github and include the iRouter.php file But i strongly recommend using composer For installing package using composer use this command

```
composer require penobit/irouter

```

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

[](#requirements)

You need PHP &gt;= 5.6 to use iRouter, although we highly recommend you [use an officially supported PHP version](https://secure.php.net/supported-versions.php) that is not EOL.

Features
--------

[](#features)

- Can be used with all HTTP Methods
- Dynamic routing with named route parameters
- Reversed routing
- Flexible regular expression routing
- Custom regexes

Examples
========

[](#examples)

Adding a route
--------------

[](#adding-a-route)

```
$router = new iRouter();

// map homepage
$router->map('GET', '/', function() {
    require __DIR__ . '/views/home.php';
});
```

Adding multiple routes at once
------------------------------

[](#adding-multiple-routes-at-once)

```
// Add multiple routes
$router->addRoutes(array(
  array('GET','/users/[i:id]', 'users#get', 'update_user'),
  array('PUT','/users/[i:id]', 'users#create', 'update_user'),
  array('PATCH','/users/[i:id]', 'users#update', 'update_user'),
  array('DELETE','/users/[i:id]', 'users#delete', 'delete_user')
));
```

Dynamic routes (with parameters)
--------------------------------

[](#dynamic-routes-with-parameters)

```
// dynamic named route
$router->map('GET|POST', '/users/[i:id]/', function($id) {
  $user = .....
  require __DIR__ . '/views/user/details.php';
}, 'user-details');
```

Generate url by named routes
----------------------------

[](#generate-url-by-named-routes)

```
// echo URL to user-details page for ID 5
echo $router->generate('user-details', ['id' => 5]); // Output: "/users/5"
```

Match types
-----------

[](#match-types)

### Adding match types

[](#adding-match-types)

```
// Add match type
$router->addMatchTypes(array('customType' => '[a-zA-Z]{2}[0-9]?'));
$router->map('GET', '/use-match-type/[customType:paramName]', function() {
    require __DIR__ . '/views/home.php';
});
```

### Default match types

[](#default-match-types)

```
*                    // 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

```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

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

Total

2

Last Release

1770d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8cbcaf2d9ebcdc5282f9dde8aeb9e6cff2d8bd8735b21669fb242e3a47dd7642?d=identicon)[penobit](/maintainers/penobit)

---

Top Contributors

[![penobit](https://avatars.githubusercontent.com/u/60283818?v=4)](https://github.com/penobit "penobit (2 commits)")

---

Tags

routerroutinglightweight

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/penobit-irouter/health.svg)

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

###  Alternatives

[symfony/routing

Maps an HTTP request to a set of configuration variables

7.6k789.4M1.8k](/packages/symfony-routing)[nikic/fast-route

Fast request router for PHP

5.3k92.4M668](/packages/nikic-fast-route)[altorouter/altorouter

A lightning fast router for PHP

1.3k3.4M68](/packages/altorouter-altorouter)[aura/router

Powerful, flexible web routing for PSR-7 requests.

5231.5M67](/packages/aura-router)[aplus/routing

Aplus Framework Routing Library

2491.6M3](/packages/aplus-routing)[pmjones/auto-route

Automatically routes HTTP request to action classes.

20158.6k6](/packages/pmjones-auto-route)

PHPackages © 2026

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