PHPackages                             packfire/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. packfire/router

AbandonedArchivedLibrary

packfire/router
===============

URL routing, easier.

1.1.1(12y ago)5185BSD-3-ClausePHPPHP &gt;=5.3.0

Since Feb 5Pushed 12y ago1 watchersCompare

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

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

\#Packfire Router

[![Build Status](https://camo.githubusercontent.com/bb6d91008f0bd41fc278ab1a0e5a5b9a0f92c71c30ef0c82b0b572303054fd81/68747470733a2f2f7472617669732d63692e6f72672f7061636b666972652f726f757465722e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/packfire/router)

Fast &amp; clean URL router for PHP 5.3+.

- No-frills URL to callback routing
- Fast route dispatch through effective OOP design
- Scalable and expansive API

Installing
----------

[](#installing)

Use [Composer](https://getcomposer.org/) to install `"packfire/router": "1.0.*"`.

1. Download `composer.phar`
2. Add `"packfire/router": "1.0.*"` under the `"require"` configuration in `composer.json`.
3. Run `php composer.phar install` to install Packfire Router.

Loading Routes from Config
--------------------------

[](#loading-routes-from-config)

Simply load your routes from any configuration format you like:

```
use Packfire\Router\FileLoader;

$loader = new FileLoader('config/routes.yml'); // loading from a YAML file
$loader = new FileLoader('config/routes.json'); // loading from a JSON file
$loader = new FileLoader('config/routes.php'); // or loading from a PHP file that returns an array of configuration

// create the Router object using the configuration
$router = $loader->load();

```

A sample configuration looks like this (in YAML):

```
routes:
  home:
    path: /
    method: get
    action: HeartCode\Blog\Controller::index
  post:
    path: /post/:id-:title
    method: get
    params:
      id: i
      title: slug
    action: HeartCode\Blog\Controller:view

```

\##Routing Requests

Routing requests is simple:

```
use Packfire\Router\FileLoader;
use Packfire\Router\CurrentRequest;

$loader = new FileLoader('config/routes.yml');
$router = $loader->load();

// load data from $_SERVER
$request = new CurrentRequest();

// Get the route based on the current request
$route = $router->route($request);

```

With the `$route` object in hand, you can easily execute the `$route` by simply running the callback:

```
// performs the action that the route needs to
$route->callback();

```

\##Generating URLs from Routes

You can perform reverse engineering by putting the route and parameters to form its full working URL:

```
use Packfire\Router\FileLoader;

$loader = new FileLoader('config/routes.yml');
$router = $loader->load();

$url = $router->generate('post', array('id' => 412, 'title' => 'maybe-this-works'));

```

`$url` will probably equals to `/post/412-maybe-this-works`

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

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

Total

5

Last Release

4453d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1743cee8bb3242229368d7fca5a7ac952932fd377d0c3d4343eb8dceea6a395e?d=identicon)[mauris](/maintainers/mauris)

---

Top Contributors

[![mauris](https://avatars.githubusercontent.com/u/996939?v=4)](https://github.com/mauris "mauris (175 commits)")

### Embed Badge

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

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

PHPackages © 2026

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