PHPackages                             lancerhe/php-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. [HTTP &amp; Networking](/categories/http)
4. /
5. lancerhe/php-router

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

lancerhe/php-router
===================

A RESTful, flexible MVC router component for PHP 5.3+. Declare rules which route HTTP requests to a controller.

v1.0.0(10y ago)0201PHPPHP &gt;=5.3.0

Since May 4Pushed 8y agoCompare

[ Source](https://github.com/lancerhe/php-router)[ Packagist](https://packagist.org/packages/lancerhe/php-router)[ RSS](/packages/lancerhe-php-router/feed)WikiDiscussions master Synced 3w ago

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

Routa
=====

[](#routa)

A RESTful, flexible MVC router component for PHP 5.4+. Declare rules which route HTTP requests to a controller.

Do we need another router?
--------------------------

[](#do-we-need-another-router)

There's loads of router components so why do we need another? Many of the existing ones are tightly coupled, poorly written. Routa is built with the following in mind:

- RESTful
- Loosely coupled
- Inspired by Ruby on Rails
- Compatible with PHP &gt;= 5.3
- Prefers convention over configuration
- Flexible and extendable
- Automated test suite

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

[](#installation)

Routa adheres to the [PSR-0](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md) spec. If you have a compatible autoloader place the contents of `lib` in your vendor directory.

Basic usage
-----------

[](#basic-usage)

Within your code create a new instance of the router class.

```
$router = new LancerHe\Router\Router;

```

This approach automatically uses the current page URL and HTTP method from the $\_SERVER super global, it's possible to override this which we'll cover later.

Next add some routes to map URLs to controller names/actions:

```
$router
    ->add('GET', '/login', 'v1#Account#login')
    ->add('GET', '/profile/:id', 'v1#User#view')
    ->add('GET', '/profile/:id/edit', 'v1#User#edit')
    ->add('GET', '/search/*', 'v1#Products#search');

```

Once all your routes have been declared match your request against them.

```
if($result = $router->match()) {
    // Assuming the url is /profile/432
    var_dump($result->getModuleName()); // returns 'v1'
    var_dump($result->getControllerName()); // returns 'User'
    var_dump($result->getActionName()); // returns 'view'
    var_dump($result->getParams); // returns ['id' => 432]
    // Load your controller…
} else {
    // Display your 404 page.
}

```

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 62.5% 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

Unknown

Total

1

Last Release

3702d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/150764812645aea7e9ac7e78774191f1eb399463038812ac22760095cb736bb2?d=identicon)[lancerhe](/maintainers/lancerhe)

---

Top Contributors

[![lancerhe](https://avatars.githubusercontent.com/u/3190175?v=4)](https://github.com/lancerhe "lancerhe (5 commits)")[![jamesmoss](https://avatars.githubusercontent.com/u/629766?v=4)](https://github.com/jamesmoss "jamesmoss (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[php-http/cache-plugin

PSR-6 Cache plugin for HTTPlug

25025.5M80](/packages/php-http-cache-plugin)[illuminate/http

The Illuminate Http package.

11937.2M6.5k](/packages/illuminate-http)[rdkafka/rdkafka

A PHP extension for Kafka

2.2k20.0k1](/packages/rdkafka-rdkafka)[httpsoft/http-message

Strict and fast implementation of PSR-7 and PSR-17

87930.4k113](/packages/httpsoft-http-message)[mezzio/mezzio-router

Router subcomponent for Mezzio

265.3M84](/packages/mezzio-mezzio-router)[serpapi/google-search-results-php

Get Google, Bing, Baidu, Ebay, Yahoo, Yandex, Home depot, Naver, Apple, Duckduckgo, Youtube search results via SerpApi.com

69122.6k](/packages/serpapi-google-search-results-php)

PHPackages © 2026

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