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

ActiveLibrary[Framework](/categories/framework)

gobline/router
==============

Router component

v3.1.0(10y ago)21472BSD-3-ClausePHPPHP &gt;=5.6.0

Since Feb 4Pushed 9y ago1 watchersCompare

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

READMEChangelogDependencies (2)Versions (22)Used By (2)

PSR-7 Router component
======================

[](#psr-7-router-component)

The purpose of routing is to **map a URL to an array of data or to a callback**, allowing to **route the request to the correct resource**. In an MVC context, this is typically a controller and a controller action.

There are two routers bundled by default:

- `Gobline\Router\LiteralRoute` (with its i18n friend `Gobline\Router\I18n\LiteralRoute`)
- `Gobline\Router\PlaceHolderRoute` (with its i18n friend `Gobline\Router\I18n\PlaceHolderRoute`)

The Router component allows to have your **URLs translated in multiple languages**, allowing to have more SEO- and user-friendly URLs.

LiteralRoute
------------

[](#literalroute)

The Literal route is for doing exact matching of the URI path.

```
$router = (new Gobline\Router\LiteralRoute('/user/profile')) // profile is the route name and /user/profile is the route to match
    ->setName('profile')
    ->values([
        'controller' => 'user',
        'action' => 'profile',
    ]);
```

I18n LiteralRoute
-----------------

[](#i18n-literalroute)

```
$router = (new Gobline\Router\LiteralRoute('/user/profile'))
    ->setName('profile')
    ->values([
        'controller' => 'user',
        'action' => 'profile',
    ])
    ->i18n([
        'fr' => '/membre/profil',
        'nl' => '/gebruiker/profiel',
    ]);
```

PlaceHolderRouter
-----------------

[](#placeholderrouter)

```
$router = (new Gobline\Router\PlaceHolderRoute('/user/:id(/)(/articles/:action(/))'))
    ->setName('profile')
    ->values([
        'controller' => 'articles',
        'action' => 'list',
    ])
    ->constraints([
        'id' => '[0-9]+',
        'action' => '[a-zA-Z]+',
    ]);
```

I18n PlaceHolderRouter
----------------------

[](#i18n-placeholderrouter)

```
$router = (new Gobline\Router\PlaceHolderRoute('/user/:id(/)(/articles/:action(/))'))
    ->setName('profile')
    ->values([
        'controller' => 'articles',
        'action' => 'list',
    ])
    ->constraints([
        'id' => '[0-9]+',
        'action' => '[a-zA-Z]+',
    ])
    ->i18n([
        'fr' => '/membre/:id(/)(/articles/:action(/))',
        'nl' => '/gebruiker/:id(/)(/artikelen/:action(/))',
        'placeholders' => [
            'action' => [
                'fr' => [
                    'list' => 'liste',
                ],
                'nl' => [
                    'list' => 'lijst',
                ],
            ],
        ],
    ]);
```

Matching a URL to a Collection of Routes
----------------------------------------

[](#matching-a-url-to-a-collection-of-routes)

```
$routeCollection = new Gobline\Router\RouteCollection();
$routeCollection
    ->get(new Gobline\Router\LiteralRoute(/*...*/))
    ->post(new Gobline\Router\PlaceHolderRouter(/*...*/));

$requestMatcher = new Gobline\Router\RequestMatcher($routeCollection);
$routeData = $requestMatcher->match($request); // psr-7 server request
```

Generating a URL Based on Route Data
------------------------------------

[](#generating-a-url-based-on-route-data)

```
$uriBuilder = new Gobline\Router\UriBuilder($routerCollection);

$url = $uriBuilder->makeUrl(new Gobline\Router\RouteData('profile', ['id' => 42]));
```

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

[](#installation)

You can install the Router component using the dependency management tool [Composer](https://getcomposer.org/). Run the *require* command to resolve and download the dependencies:

```
composer require gobline/router

```

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity67

Established project with proven stability

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

Total

21

Last Release

3846d ago

Major Versions

v1.2.5 → v2.0.02015-12-03

v2.0.1 → v3.0.02015-12-20

PHP version history (2 changes)v1.0.0PHP &gt;=5.4.0

v2.0.0PHP &gt;=5.6.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/1564a230fe2f5125b0504cf6b6fe1e829face1a5d20ec663b3b8d22843312c7d?d=identicon)[mdecaffmeyer](/maintainers/mdecaffmeyer)

---

Tags

routerroutinggobline

### Embed Badge

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

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

###  Alternatives

[symfony/symfony

The Symfony PHP framework

31.4k87.2M2.2k](/packages/symfony-symfony)[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.5k](/packages/aws-aws-sdk-php)[slim/slim

Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs

12.3k52.9M1.4k](/packages/slim-slim)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k36](/packages/neuron-core-neuron-ai)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k13](/packages/tempest-framework)[klein/klein

A lightning fast router for PHP

2.7k1.1M31](/packages/klein-klein)

PHPackages © 2026

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