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

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

rodri/simple-router
===================

A simple router to API applications.

v1.3.3-alpha(4y ago)252[2 issues](https://github.com/Rod1Andrade/simple-router/issues)MITPHPPHP ^8.0

Since Jul 10Pushed 4y ago1 watchersCompare

[ Source](https://github.com/Rod1Andrade/simple-router)[ Packagist](https://packagist.org/packages/rodri/simple-router)[ RSS](/packages/rodri-simple-router/feed)WikiDiscussions main Synced 5d ago

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

Rodri\\SimpleRouter
===================

[](#rodrisimplerouter)

[![](https://camo.githubusercontent.com/911a83e2aa6fe73660ab613629a95c76622bf03049a7344e80c5ea72d4ef9c7d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e302d626c7565)](https://camo.githubusercontent.com/911a83e2aa6fe73660ab613629a95c76622bf03049a7344e80c5ea72d4ef9c7d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e302d626c7565)

Router for API applications - It’s a simple route builder that makes it’s process of defining the route far more simple and faster.

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

[](#installation)

```
composer require rodri/simple-router:1.1.2-alpha
```

How it works?
-------------

[](#how-it-works)

Check the wiki:

- When instantiate a new Router is necessary set the controller namespace.
- To pass params for a router just name the parameter with `:`. for example: `/hello/:id`, in this case `:id` is changed to request passed value.
- To set a router is necessary start with bar `/`, but don't need to finish.
- The first parameter of any verb method is an array `[]`, the first element of array need be the router name. The others have you own associative name, like `['middleware' => 'MiddlewareClass']`.
- Its possible have one or many middlewares to a unique router or a group of routes. For one middleware use `['middleware' => 'NameMiddlewareClass']`, to many use `['middleware' => ['OneMiddleware', 'AnotherMiddleware', 'OneMoreMiddleware']`.

Example
-------

[](#example)

```
use Rodri\SimpleRouter\Helpers\Header;
use Rodri\SimpleRouter\Router;

# Application Routers
$router = new Router();

$router->headerConfigs([
    Header::APPLICATION_JSON_UTF8,
]);

$router->setControllerNamespace('Rodri\SimpleRouter\Controllers');
$router->setMiddlewareNamespace('Rodri\SimpleRouter\Middlewares');

$router->debug(true);

# Routers without group
$router->get(['/hello'], 'HelloControllerExample#hello');
$router->get(['/hello/message/:id'], 'HelloControllerExample#helloByMessage');
$router->post(['/post'], 'HelloControllerExample#postTest');
$router->put(['/post'], 'HelloControllerExample#postTest');
$router->patch(['/post'], 'HelloControllerExample#postTest');
$router->delete(['/post'], 'HelloControllerExample#postTest');

# Router with group
$router->group(['/group/test'], function (Router $router) {
    $router->get([''], 'HelloControllerExample#hello');
    $router->get(['/:id'], 'HelloControllerExample#helloByMessage');
    $router->post([''], 'HelloControllerExample#postTest');
});

$router->group(['/group'], function (Router $router) {
    $router->get([''], 'HelloControllerExample#hello');
    $router->get(['/:id'], 'HelloControllerExample#helloByMessage');
    $router->post([''], 'HelloControllerExample#postTest');
});

# Router with a group and middleware
$router->group(['/request', 'middleware' => 'OtherMiddleware'], function (Router $router) {
    $router->get(['/get', 'middleware' => 'FailedMiddleware'], 'RequestController#get');
    $router->post(['/post'], 'RequestController#post');
});

# Group Route with middlewares
$router->group(['/request', 'middleware' => ['OtherMiddleware', 'GetMiddleware']], function (Router $router) {
    $router->get(['/get', 'middleware' => 'FailedMiddleware'], 'RequestController#get');
    $router->post(['/post'], 'RequestController#post');
});

# ALone router with middlewares
$router->get(['/aloneGet', 'middleware' => ['GetMiddleware', 'OtherMiddleware', 'FailedMiddleware']], 'RequestController#get');

# Execution of set router
$router->dispatch();
```

License
=======

[](#license)

MIT

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

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

Total

6

Last Release

1752d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f39322c26ad81b63197a8d18b2d4c891124352c3cfa1d62b04e46306c7919554?d=identicon)[Rod1Andrade](/maintainers/Rod1Andrade)

---

Top Contributors

[![Rod1Andrade](https://avatars.githubusercontent.com/u/51142291?v=4)](https://github.com/Rod1Andrade "Rod1Andrade (45 commits)")

---

Tags

api-routerhttp-routerphp-routerrouterhttprouterrouting

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[miladrahimi/phprouter

A powerful, lightweight, and very fast HTTP URL router for PHP projects.

20832.6k2](/packages/miladrahimi-phprouter)[wilaak/radix-router

High-performance radix tree based HTTP request router

612.8k5](/packages/wilaak-radix-router)

PHPackages © 2026

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