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 1mo 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 43% 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

3657d 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

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M315](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[nyholm/psr7

A fast PHP7 implementation of PSR-7

1.3k235.4M2.4k](/packages/nyholm-psr7)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M290](/packages/pusher-pusher-php-server)[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78126.4M414](/packages/react-http)

PHPackages © 2026

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