PHPackages                             guyliangilsing/php-abstract-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. [Framework](/categories/framework)
4. /
5. guyliangilsing/php-abstract-router

ActiveLibrary[Framework](/categories/framework)

guyliangilsing/php-abstract-router
==================================

A simple package that provides you with a framework agnostic router.

1.1.1(3y ago)0371MITPHP

Since May 16Pushed 3y ago1 watchersCompare

[ Source](https://github.com/GuylianGilsing/PHPAbstractRouter)[ Packagist](https://packagist.org/packages/guyliangilsing/php-abstract-router)[ RSS](/packages/guyliangilsing-php-abstract-router/feed)WikiDiscussions main Synced 4w ago

READMEChangelog (4)Dependencies (2)Versions (5)Used By (1)

PHPAbstractRouter
=================

[](#phpabstractrouter)

A simple package that provides you with a framework agnostic router.

Table of contents
-----------------

[](#table-of-contents)

- [PHPAbstractRouter](#phpabstractrouter)
    - [Table of contents](#table-of-contents)
    - [What is this exactly?](#what-is-this-exactly)
    - [Installation](#installation)
    - [Usage](#usage)
        - [Defining routes manually](#defining-routes-manually)
        - [Defining routes through attributes](#defining-routes-through-attributes)
        - [Defining group routes](#defining-group-routes)
        - [Integrating a routing backend](#integrating-a-routing-backend)

What is this exactly?
---------------------

[](#what-is-this-exactly)

PHPAbstractRouter is a framework agnostic router that lets you define routes manually, or through attributes. It is up to the person using this package to provide the router with an actual routing backend. A backend could be a framework (like slim 4), or an actual router (like FastRoute).

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

[](#installation)

```
$ composer require guyliangilsing/php-abstract-router
```

Usage
-----

[](#usage)

### Defining routes manually

[](#defining-routes-manually)

You can manually define routes through the `Router` class:

```
use use PHPAbstractRouter\HTTP\Router;;

$routeRegisterer = // Your bridge class...
$router = new Router($routeRegisterer);

$router->get('/', MyController::class,'renderIndex');
$router->get('/about', MyController::class, 'renderAbout');
```

### Defining routes through attributes

[](#defining-routes-through-attributes)

You can define your routes inside classes through attributes:

```
use PHPAbstractRouter\HTTP\Attributes\GET;
use PHPAbstractRouter\HTTP\Attributes\Group;
use PHPAbstractRouter\HTTP\Attributes\POST;

#[Group('/test')]
final class MyController
{
    #[GET('/')]
    public function renderIndex(): string
    {
        return "index.php";
    }

    #[POST('/')]
    public function indexPOST(): string
    {
        return "POST index.php";
    }

    #[GET('/about')]
    public function renderAbout(): string
    {
        return "about.php";
    }

    #[POST('/about')]
    public function aboutPOST(): string
    {
        return "POST about.php";
    }
}
```

Once you have defined your routes, you then can let the `RouterFacade` collect them:

```
use use PHPAbstractRouter\HTTP\Router;;

$routeRegisterer = // Your bridge class...
$router = new Router($routeRegisterer);

$router->fromClass(MyController::class);
```

### Defining group routes

[](#defining-group-routes)

Group routes can be defined through the `GroupRouter` class:

```
use PHPAbstractRouter\HTTP\GroupRouter;
use PHPAbstractRouter\HTTP\Router;

$dispatcher = // Your custom dispatcher here...
$router = new RouterFacade($dispatcher);

$router->group('/test', function(GroupRouter $group) {
    $group->get('', MyController::class, 'renderIndex');
    $group->get('/about', MyController::class, 'renderAbout');
});
```

### Integrating a routing backend

[](#integrating-a-routing-backend)

To integrate your preferred routing backend, you only have to implement the `BackendRouteRegistererInterface` interface:

```
use PHPAbstractRouter\HTTP\BackendRouteRegistererInterface;

final class BackendRouteRegisterer implements BackendRouteRegistererInterface
{
    public function route(HTTPRoute $route): void
    {
        // Todo:: Implement your registration logic here...
    }

    public function routeGroup(HTTPRouteGroup $group): void
    {
        // Todo:: Implement your registration logic here...
    }
}
```

Once you have implemented this interface, you can pass it to the `Router` class through its constructor.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity51

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

Total

3

Last Release

1425d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/481d2bed23d6b8737e7fcbd874666db22281ee138c03d040f251a7915369eadd?d=identicon)[GuylianGilsing](/maintainers/GuylianGilsing)

---

Top Contributors

[![GuylianGilsing](https://avatars.githubusercontent.com/u/47211491?v=4)](https://github.com/GuylianGilsing "GuylianGilsing (8 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/guyliangilsing-php-abstract-router/health.svg)

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

###  Alternatives

[laravel/telescope

An elegant debug assistant for the Laravel framework.

5.2k67.8M190](/packages/laravel-telescope)[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M529](/packages/laravel-passport)[spiral/roadrunner

RoadRunner: High-performance PHP application server and process manager written in Go and powered with plugins

8.4k12.2M84](/packages/spiral-roadrunner)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M255](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

708181.8M591](/packages/laravel-prompts)

PHPackages © 2026

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