PHPackages                             altorouter/altorouter - 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. altorouter/altorouter

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

altorouter/altorouter
=====================

A lightning fast router for PHP

2.0.3(1y ago)1.3k3.4M—6.4%232[3 PRs](https://github.com/dannyvankooten/AltoRouter/pulls)20MITPHPPHP &gt;=7.3CI passing

Since Oct 7Pushed 1y ago60 watchersCompare

[ Source](https://github.com/dannyvankooten/AltoRouter)[ Packagist](https://packagist.org/packages/altorouter/altorouter)[ Docs](https://github.com/dannyvankooten/AltoRouter)[ RSS](/packages/altorouter-altorouter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (2)Versions (9)Used By (20)

AltoRouter [![PHP status](https://github.com/dannyvankooten/AltoRouter/workflows/PHP/badge.svg)](https://github.com/dannyvankooten/AltoRouter/workflows/PHP/badge.svg) [![Latest Stable Version](https://camo.githubusercontent.com/3822cda2e4ca4f84accbeb7821b31540948714cb06dafb37f52318b82bb49c96/68747470733a2f2f706f7365722e707567782e6f72672f616c746f726f757465722f616c746f726f757465722f762f737461626c652e737667)](https://packagist.org/packages/altorouter/altorouter) [![License](https://camo.githubusercontent.com/4404d064f02d957e41d4ff9472036092b478cd65f164396a16330f9aa0286e00/68747470733a2f2f706f7365722e707567782e6f72672f616c746f726f757465722f616c746f726f757465722f6c6963656e73652e737667)](https://packagist.org/packages/altorouter/altorouter)
========================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#altorouter----)

AltoRouter is a small but powerful routing class, heavily inspired by [klein.php](https://github.com/chriso/klein.php/).

```
$router = new AltoRouter();

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

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

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

Features
--------

[](#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
---------------

[](#getting-started)

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

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

Contributors
------------

[](#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)

License
-------

[](#license)

MIT License

Copyright (c) 2012 Danny van Kooten

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

56

—

FairBetter than 98% of packages

Maintenance41

Moderate activity, may be stable

Popularity67

Solid adoption and visibility

Community48

Growing community involvement

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 60.7% 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 ~586 days

Recently: every ~831 days

Total

8

Last Release

498d ago

Major Versions

v1.2.0 → 2.02019-11-10

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

2.0PHP &gt;=5.6.0

2.0.3PHP &gt;=7.3

### Community

Maintainers

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

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

![](https://avatars.githubusercontent.com/u/885856?v=4)[Danny van Kooten](/maintainers/dannyvankooten)[@dannyvankooten](https://github.com/dannyvankooten)

![](https://www.gravatar.com/avatar/3cc421c2f927c732cd04ddfef5a2e952adcd6f7607141c85d9f0a6ac2d80d992?d=identicon)[niahoo](/maintainers/niahoo)

---

Top Contributors

[![dannyvankooten](https://avatars.githubusercontent.com/u/885856?v=4)](https://github.com/dannyvankooten "dannyvankooten (88 commits)")[![koenpunt](https://avatars.githubusercontent.com/u/351038?v=4)](https://github.com/koenpunt "koenpunt (40 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)")[![xpetter](https://avatars.githubusercontent.com/u/25478802?v=4)](https://github.com/xpetter "xpetter (2 commits)")[![sergey-nagaytsev](https://avatars.githubusercontent.com/u/580897?v=4)](https://github.com/sergey-nagaytsev "sergey-nagaytsev (2 commits)")[![Nyholm](https://avatars.githubusercontent.com/u/1275206?v=4)](https://github.com/Nyholm "Nyholm (1 commits)")[![frosso](https://avatars.githubusercontent.com/u/273592?v=4)](https://github.com/frosso "frosso (1 commits)")[![AliAzizi](https://avatars.githubusercontent.com/u/76846698?v=4)](https://github.com/AliAzizi "AliAzizi (1 commits)")[![MathB](https://avatars.githubusercontent.com/u/6626821?v=4)](https://github.com/MathB "MathB (1 commits)")

---

Tags

phproutingrouterroutinglightweight

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  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)[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)[miladrahimi/phprouter

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

20832.6k2](/packages/miladrahimi-phprouter)

PHPackages © 2026

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