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

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

gacela-project/router
=====================

A minimalistic HTTP router.

0.13.0(3w ago)174.4k11MITPHPPHP &gt;=8.1CI passing

Since Apr 10Pushed 3w ago2 watchersCompare

[ Source](https://github.com/gacela-project/router)[ Packagist](https://packagist.org/packages/gacela-project/router)[ Fund](https://chemaclass.com/sponsor)[ RSS](/packages/gacela-project-router/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (10)Dependencies (18)Versions (16)Used By (1)

Gacela Router
=============

[](#gacela-router)

A minimalistic HTTP router, ideal for your proof-of-concept projects and decoupled controllers.

 [ ![GitHub Build Status](https://github.com/gacela-project/router/workflows/CI/badge.svg) ](https://github.com/gacela-project/router/actions) [ ![Scrutinizer Code Quality](https://camo.githubusercontent.com/9889ae31fa71eaa2c79eb42a7e99b46c0b108b2461e1b5ba43f326f6ee04cf96/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f676163656c612d70726f6a6563742f726f757465722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d61696e) ](https://scrutinizer-ci.com/g/gacela-project/router/?branch=main) [ ![Scrutinizer Code Coverage](https://camo.githubusercontent.com/5e25f5ab27516e682dadc5830d80b3d97a23852e092a9e706770c78f8eda8dc9/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f676163656c612d70726f6a6563742f726f757465722f6261646765732f636f7665726167652e706e673f623d6d61696e) ](https://scrutinizer-ci.com/g/gacela-project/router/?branch=main) [ ![Psalm Type-coverage Status](https://camo.githubusercontent.com/824d0e420c45f2c187e8ae0134d207d3e10c13ed3df119542da20d9f0630dbf5/68747470733a2f2f73686570686572642e6465762f6769746875622f676163656c612d70726f6a6563742f726f757465722f636f7665726167652e737667) ](https://shepherd.dev/github/gacela-project/router) [ ![Mutation testing badge](https://camo.githubusercontent.com/3e78644fb833606e21bdbdd29c1514210aaf03022d2c7fd812021edcc88acab6/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d253246676163656c612d70726f6a656374253246726f757465722532466d61696e) ](https://dashboard.stryker-mutator.io/reports/github.com/gacela-project/router/main) [ ![MIT Software License](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667) ](https://github.com/gacela-project/router/blob/main/LICENSE)

### Why?

[](#why)

There are many other routers out there. Eg: using Symfony Framework, Laravel, etc... however, these are really rich in features which means they add a lot of accidental complexity and dependencies to your vendor, that you might want to avoid. At least for your proof-of-concept project.

Gacela Router doesn't aim to be the best router that can do everything, but a light router to have the bare minimum code, ideal for your simple ideas to emerge.

For a POC, we value simplicity over a rich-feature library.

### Requirements

[](#requirements)

- PHP `>=8.1`

### Installation

[](#installation)

```
composer require gacela-project/router
```

### Example

[](#example)

```
# Request only the parameters you need: Routes, Bindings, Handlers, Middlewares
# All except Routes are optional, and you can place them in any order.

$router = new Router(function (Routes $routes, Bindings $bindings, Handlers $handlers, Middlewares $middlewares) {

    // Custom redirections
    $routes->redirect('docs', 'https://gacela-project.com/');

    // Matching a route coming from a particular or any custom HTTP methods
    $routes->get('custom', CustomController::class, '__invoke');
    $routes->post('custom', CustomController::class, 'customAction');
    $routes->any('custom', CustomController::class);

    // Matching a route coming from multiple HTTP methods
    $routes->match(['GET', 'POST'], '/', CustomController::class);

    // Binding custom dependencies on your controllers
    $routes->get('custom/{number}', CustomControllerWithDependencies::class, 'customAction');
    $bindings->bind(SomeDependencyInterface::class, SomeDependencyConcrete::class);

    // Handle custom Exceptions with class-string|callable
    $handlers->handle(NotFound404Exception::class, NotFound404ExceptionHandler::class);

    // Apply middleware to all routes
    $middlewares->add(new GlobalMiddleware());

    // Use individual middleware to a route
    $routes->get('admin', AdminController::class)->middleware(new AuthMiddleware());

    // Or define a middleware group
    $middlewares->group('web', [
        new SessionMiddleware(),
        new CsrfMiddleware(),
    ]);

    // And apply the group to the route
    $routes->get('/', Controller::class)->middleware('web');

});

$router->run();
```

### Documentation

[](#documentation)

Full docs live in the [`docs/`](docs/README.md) folder:

- [Getting started](docs/getting-started.md)
- [Routing](docs/routing.md) — HTTP methods, controllers, path patterns and parameters
- [Responses](docs/responses.md) — strings, `Stringable`, `Response`, `JsonResponse`
- [The request](docs/request.md) — reading input and injecting `Request`
- [Middleware](docs/middleware.md) — global, per-route and grouped
- [Error handling](docs/error-handling.md) — mapping exceptions to handlers
- [Use it within Gacela](docs/gacela-integration.md) — the `RouterGacelaConfig` adapter and plugins

### Working demo

[](#working-demo)

For a working example run `composer serve` and check the `example/example.php`

> TIP: `composer serve` is equivalent to:
>
> ```
> php -S localhost:8081 example/example.php
> ```

###  Health Score

51

—

FairBetter than 95% of packages

Maintenance94

Actively maintained with recent releases

Popularity31

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 57.7% 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 ~92 days

Recently: every ~292 days

Total

14

Last Release

25d ago

PHP version history (2 changes)0.1.0PHP &gt;=8.0.2

0.12.1PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/3d166420c6770c5941e10bd68b2d26501eabb432e280d8e6eba0a344bcc1e5ae?d=identicon)[Chemaclass](/maintainers/Chemaclass)

![](https://avatars.githubusercontent.com/u/6381924?v=4)[Jesus Valera Reales](/maintainers/JesusValeraDev)[@JesusValeraDev](https://github.com/JesusValeraDev)

---

Top Contributors

[![Chemaclass](https://avatars.githubusercontent.com/u/5256287?v=4)](https://github.com/Chemaclass "Chemaclass (123 commits)")[![antonio-gg-dev](https://avatars.githubusercontent.com/u/13595197?v=4)](https://github.com/antonio-gg-dev "antonio-gg-dev (53 commits)")[![JesusValeraDev](https://avatars.githubusercontent.com/u/6381924?v=4)](https://github.com/JesusValeraDev "JesusValeraDev (30 commits)")[![ynnoig](https://avatars.githubusercontent.com/u/22853912?v=4)](https://github.com/ynnoig "ynnoig (7 commits)")

---

Tags

gacelahttpphprouter

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[php-http/cache-plugin

PSR-6 Cache plugin for HTTPlug

25026.8M85](/packages/php-http-cache-plugin)[gacela-project/gacela

Gacela helps you separate your project into modules

134203.7k16](/packages/gacela-project-gacela)[httpsoft/http-message

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

85997.3k131](/packages/httpsoft-http-message)[thesis/nats

Async (fiber based) client for Nats.

758.3k](/packages/thesis-nats)

PHPackages © 2026

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