PHPackages                             hakimch/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. [Framework](/categories/framework)
4. /
5. hakimch/router

AbandonedArchivedLibrary[Framework](/categories/framework)

hakimch/router
==============

A lightning fast router for PHP

v2.0.0(8y ago)318MITPHPPHP &gt;=5.6.0

Since Oct 7Pushed 8y ago1 watchersCompare

[ Source](https://github.com/HakimCh/Router)[ Packagist](https://packagist.org/packages/hakimch/router)[ Docs](https://github.com/HakimCh/Router)[ RSS](/packages/hakimch-router/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (2)Versions (5)Used By (0)

Router [![SensioLabsInsight](https://camo.githubusercontent.com/6820c2448d0188edb5cf6717c08a529c3b2eb02a33932dfd50c1d8aca7fd5326/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f32616339383937332d373332612d346439392d383235392d6464666464303233656665352f736d616c6c2e706e67)](https://insight.sensiolabs.com/projects/2ac98973-732a-4d99-8259-ddfdd023efe5) [![Build Status](https://camo.githubusercontent.com/b9e1d35eda1f5e5e53c723f79551d90da4b26603a5eb0771434625219b18edd2/68747470733a2f2f7472617669732d63692e6f72672f48616b696d43682f526f757465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/HakimCh/Router) [![Code Climate](https://camo.githubusercontent.com/1ad8cc5b78684e432fa7f8ddf7ef64b37eb5c28c18549691988e6590054593ac/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f48616b696d43682f526f757465722f6261646765732f6770612e737667)](https://codeclimate.com/github/HakimCh/Router) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/c0ccaefa9d288a8d5ce02378808bf1542547051f892536e54a1e5dcb0d65505f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f48616b696d43682f526f757465722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/HakimCh/Router/?branch=master) [![Build Status](https://camo.githubusercontent.com/dd89fe084cd49d35039a018ecc96edb1044d9fbeff16d4252087f3f92960863d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f48616b696d43682f526f757465722f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/HakimCh/Router/build-status/master) [![Code Coverage](https://camo.githubusercontent.com/c5e103fc52f3e55127c5fdb4e6c9ede474e3c67c30cb3df6b9d8ad181be7037e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f48616b696d43682f526f757465722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/HakimCh/Router/?branch=master)
========================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#router------)

Router is a small but powerful routing class for PHP 5.6+, forked from [AltoRouter.php](https://github.com/dannyvankooten/AltoRouter/).

```
$parser = new \HakimCh\Http\RouterParser();
$router = new \HakimCh\Http\Router($parser, [], '', $_SERVER);

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

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

// map users details page (get, post, delete, put, patch, update)
$router->get('/users/[i:id]/', function( $id ) {
  $user = .....
  require __DIR__ . '/views/user/details.php';
});

## Features

* Can be used with all HTTP Methods
* Dynamic routing with named route parameters
* Reversed routing
* Flexible regular expression routing (inspired by [Sinatra](http://www.sinatrarb.com/))
* Custom regexes

## Getting started

You need PHP >= 5.6 to use Router.

- [Install AltoRouter](http://altorouter.com/usage/install.html)
- [Rewrite all requests to AltoRouter](http://altorouter.com/usage/rewrite-requests.html)
- [Map your routes](http://altorouter.com/usage/mapping-routes.html)
- [Match requests](http://altorouter.com/usage/matching-requests.html)
- [Process the request your preferred way](http://altorouter.com/usage/processing-requests.html)

## Contributors
- [Danny van Kooten](https://github.com/dannyvankooten)
- [Koen Punt](https://github.com/koenpunt)
- [John Long](https://github.com/adduc)
- [Niahoo Osef](https://github.com/niahoo)
- [Hakim Ch](https://github.com/HakimCh)

## License

(MIT License)

Copyright (c) 2017 Hakim Ch

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

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Total

4

Last Release

3138d ago

Major Versions

v1.1.0 → v2.0.02017-10-10

PHP version history (2 changes)v1.0.0PHP &gt;=5.3.0

v2.0.0PHP &gt;=5.6.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/1d91fea4a9e25d7a730a4ae912c55ce77469c25da13c1339c4c405d93b9bd1d9?d=identicon)[HakimCh](/maintainers/HakimCh)

---

Top Contributors

[![dannyvankooten](https://avatars.githubusercontent.com/u/885856?v=4)](https://github.com/dannyvankooten "dannyvankooten (43 commits)")[![koenpunt](https://avatars.githubusercontent.com/u/351038?v=4)](https://github.com/koenpunt "koenpunt (31 commits)")[![HakimCh](https://avatars.githubusercontent.com/u/13296222?v=4)](https://github.com/HakimCh "HakimCh (8 commits)")[![adduc](https://avatars.githubusercontent.com/u/44527?v=4)](https://github.com/adduc "adduc (6 commits)")[![SebastianPoell](https://avatars.githubusercontent.com/u/1398398?v=4)](https://github.com/SebastianPoell "SebastianPoell (3 commits)")[![sergey-nagaytsev](https://avatars.githubusercontent.com/u/580897?v=4)](https://github.com/sergey-nagaytsev "sergey-nagaytsev (2 commits)")[![frosso](https://avatars.githubusercontent.com/u/273592?v=4)](https://github.com/frosso "frosso (1 commits)")[![MathB](https://avatars.githubusercontent.com/u/6626821?v=4)](https://github.com/MathB "MathB (1 commits)")[![Nyholm](https://avatars.githubusercontent.com/u/1275206?v=4)](https://github.com/Nyholm "Nyholm (1 commits)")

---

Tags

routerroutinglightweight

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[klein/klein

A lightning fast router for PHP

2.7k1.1M31](/packages/klein-klein)[pecee/simple-router

Simple, fast PHP router that is easy to get integrated and in almost any project. Heavily inspired by the Laravel router.

696214.6k17](/packages/pecee-simple-router)[vlucas/bulletphp

A heierarchical resource-oriented micro-framework built on nested closures instead of route-based callbacks

41949.9k1](/packages/vlucas-bulletphp)[izniburak/router

simple router class for php

23522.6k7](/packages/izniburak-router)[vectorface/snappy-router

A quick and snappy routing framework.

4614.7k](/packages/vectorface-snappy-router)[thewunder/croute

Convention based routing for PHP

1317.4k](/packages/thewunder-croute)

PHPackages © 2026

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