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

ActiveLibrary[Framework](/categories/framework)

altarouter/altarouter
=====================

A lightning fast router for PHP with attribute and caching capabilities

1.07(1y ago)044MITPHPPHP &gt;=8.0

Since Nov 6Pushed 1y agoCompare

[ Source](https://github.com/olivierbussier/AltaRouter)[ Packagist](https://packagist.org/packages/altarouter/altarouter)[ Docs](https://github.com/olivierbussier/AltaRouter)[ RSS](/packages/altarouter-altarouter/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (2)Versions (9)Used By (0)

AltaRouter [![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)
========================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#altarouter----)

AltaRouter is a fork of AltoRouter, light weighted package adding route attributes capabilities and efficient route caching and checking mechanism

Usage:

```
use Route;

// map homepage controller
#[Route(method: 'get', route: 'home', name: 'home-page')]
public function home()
{
    ...
}

// Route matching
// Optional parameters 'route' and 'httpMethod', match could fetch them directly from $_SERVER

$match = $this->match($route, $httpMethod);
...
```

AltaRouter Features
-------------------

[](#altarouter-features)

- Routes created automatically by AltaRouter using attribute mechanism
- Routes cached in a php file, this file is rebuild if the controller file of the requested route more recent than cache file
- Instead of multiple 'map' call, a single include with all routes in an array is done at init

And of course, as AltoRouter
----------------------------

[](#and-of-course-as-altorouter)

- 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

This doc covers only AltaRouter usage with php attributes, refer to the [AltoRouter documentation](https://dannyvankooten.github.io/AltoRouter) for everything else

Getting started
---------------

[](#getting-started)

You need PHP &gt;= 8.0 to use AltoRouter.

AltaRouter installation
-----------------------

[](#altarouter-installation)

AltaRouter respect PSR4 autoloading rules. The best way to include AltaRouter in your project is to use composer

`composer require altarouter/altarouter`

Follow [Rewrite all requests to AltoRouter](https://dannyvankooten.github.io/AltoRouter//usage/rewrite-requests.html) explanations to redirect http requests to altarouter

Route mapping
-------------

[](#route-mapping)

Route mapping could be done using 'map' method, see [Map your routes](https://dannyvankooten.github.io/AltoRouter//usage/mapping-routes.html) for usage explanations

AltaRouter provides you the capability to declare routes on top of the controller:

```
#[Route(method: method, route: url, name: routeName)
```

### Description of parameters:

[](#description-of-parameters)

**method**

- (string) : 'get', 'post', 'put', 'delete', ...
- (array) : \['get', 'post'\]

route:

- (string) : url of the route, like 'account/rights'

name:

- (string optional) : name of the route. The route name is mandatory if you want to build later url routes for buttons or anchors

### Match requests amon defined routes

[](#match-requests-amon-defined-routes)

The route matching is identical at those defined in Altorouter docs : [Match requests](https://dannyvankooten.github.io/AltoRouter//usage/matching-requests.html) and [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

29

—

LowBetter than 57% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

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

Recently: every ~12 days

Total

8

Last Release

555d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/14273593?v=4)[olbus](/maintainers/olbus)[@olbus](https://github.com/olbus)

---

Top Contributors

[![dannyvankooten](https://avatars.githubusercontent.com/u/885856?v=4)](https://github.com/dannyvankooten "dannyvankooten (82 commits)")[![koenpunt](https://avatars.githubusercontent.com/u/351038?v=4)](https://github.com/koenpunt "koenpunt (40 commits)")[![olivierbussier](https://avatars.githubusercontent.com/u/6491159?v=4)](https://github.com/olivierbussier "olivierbussier (9 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)")[![Nyholm](https://avatars.githubusercontent.com/u/1275206?v=4)](https://github.com/Nyholm "Nyholm (1 commits)")[![MathB](https://avatars.githubusercontent.com/u/6626821?v=4)](https://github.com/MathB "MathB (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)")

---

Tags

attributesroutingrouterroutinglightweight

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  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.

675231.0k18](/packages/pecee-simple-router)[vlucas/bulletphp

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

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

simple router class for php

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

A quick and snappy routing framework.

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

Convention based routing for PHP

1419.4k](/packages/thewunder-croute)

PHPackages © 2026

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