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

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

carlosrivera/nano-router
========================

Quick and dirt PHP router for testing.

v0.1.2(5y ago)119MITPHPCI failing

Since Dec 8Pushed 5y ago1 watchersCompare

[ Source](https://github.com/carlosrivera/nano-router)[ Packagist](https://packagist.org/packages/carlosrivera/nano-router)[ RSS](/packages/carlosrivera-nano-router/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (1)Versions (5)Used By (0)

NanoRouter
==========

[](#nanorouter)

[![Build Status](https://camo.githubusercontent.com/9a7bfe612edc98649c869f7be37eb157cdd0047555d62881404ff659837d580c/68747470733a2f2f7472617669732d63692e6f72672f6361726c6f737269766572612f6e616e6f2d726f757465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/carlosrivera/nano-router) [![Latest Stable Version](https://camo.githubusercontent.com/5e1840f025c8a12ab34eb4f25353b1e39ec53abd3f8935dbc9b42aa760e345d5/68747470733a2f2f706f7365722e707567782e6f72672f6361726c6f737269766572612f6e616e6f2d726f757465722f762f737461626c65)](https://packagist.org/packages/carlosrivera/nano-router) [![Total Downloads](https://camo.githubusercontent.com/aea8390c66d055b24ab3233ddc8421eb6055ecb8cd721d002f9cebbdfb3156fc/68747470733a2f2f706f7365722e707567782e6f72672f6361726c6f737269766572612f6e616e6f2d726f757465722f646f776e6c6f616473)](https://packagist.org/packages/carlosrivera/nano-router) [![Latest Unstable Version](https://camo.githubusercontent.com/13620593cadab8b02c4c6cafc6c0fb4056296f7a2f3f514ecf73d57d75144630/68747470733a2f2f706f7365722e707567782e6f72672f6361726c6f737269766572612f6e616e6f2d726f757465722f762f756e737461626c65)](https://packagist.org/packages/carlosrivera/nano-router) [![License](https://camo.githubusercontent.com/ca107529cdb48596c03cd51c6a933eb558112b13689b115c51c81f17c0c92f85/68747470733a2f2f706f7365722e707567782e6f72672f6361726c6f737269766572612f6e616e6f2d726f757465722f6c6963656e7365)](https://packagist.org/packages/carlosrivera/nano-router) [![codecov](https://camo.githubusercontent.com/6ae2e759ea49ee52b91977badb44ce35fc5927b140e1a88ed550c0826d1cdfb9/68747470733a2f2f636f6465636f762e696f2f67682f6361726c6f737269766572612f6e616e6f2d726f757465722f6272616e63682f6d61737465722f67726170682f62616467652e7376673f746f6b656e3d534e59574a4a53434b38)](https://codecov.io/gh/carlosrivera/nano-router)

Simple router made to do quick and dirty test over PHP (primary API's developed on other platforms), not intented to be a production or complex framework but as a way to test simple stuff in an scenario with zero configurations.

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

[](#installation)

#### Composer

[](#composer)

You can install the nano-framework using composer:

```
composer require carlosrivera/nano-router
```

How to use it
-------------

[](#how-to-use-it)

```
// Load and create the router
include 'vendor/autoload.php';

use \Nano\Router\Router;

$router = new Router();

// Add some routers, it support static and dynamic ones
$router->any('/', function() {
    echo "from index";
});

// For dynamic routes you can use regex or wildcards enclosed by
$router->get('/dynamic//', function($slug, $id) {
    echo "from dynamic with args: { slug: " . $slug . ", id: ". $id . "}";
});

// finally, just process the current route
$router->dispatch();
```

### Hooks

[](#hooks)

You can also add hook closures before proccesing the actual call, for example to validate a session or translate according the request.

```
$router->hooks->beforeRequest->add(function() {
	echo "before request firts hook \n";
});

$router->hooks->beforeRequest->add(function() {
	echo "before request second hook \n";
});

$router->hooks->afterRequest->add(function() {
	echo "after request hook \n";
});
```

Pretty URL's
------------

[](#pretty-urls)

The main purpose of this library was to be able to route to pretty url's, to achieve this you can redirect all your request to your main file, or write the path after you script name `localhost/index.php/myroute/path`:

```
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php [L,QSA]
```

MIT Licence
-----------

[](#mit-licence)

Copyright (c) 2015

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

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 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 ~897 days

Total

3

Last Release

2063d ago

### Community

Maintainers

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

---

Top Contributors

[![carlosrivera](https://avatars.githubusercontent.com/u/1478124?v=4)](https://github.com/carlosrivera "carlosrivera (12 commits)")

---

Tags

nanoframeworkphprouterrouter

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[symfony/routing

Maps an HTTP request to a set of configuration variables

7.6k819.6M2.3k](/packages/symfony-routing)[nikic/fast-route

Fast request router for PHP

5.3k95.8M742](/packages/nikic-fast-route)[altorouter/altorouter

A lightning fast router for PHP

1.3k3.4M73](/packages/altorouter-altorouter)[league/route

Fast routing and dispatch component including PSR-15 middleware, built on top of FastRoute.

6673.2M140](/packages/league-route)[aura/router

Powerful, flexible web routing for PSR-7 requests.

5001.5M69](/packages/aura-router)[coffeecode/router

A classic CoffeeCode Router is easy, fast and extremely uncomplicated. Create and manage your routes in minutes!

180114.0k5](/packages/coffeecode-router)

PHPackages © 2026

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