PHPackages                             yasiekz/router-bundle - 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. [API Development](/categories/api)
4. /
5. yasiekz/router-bundle

ActiveSymfony-bundle[API Development](/categories/api)

yasiekz/router-bundle
=====================

Bundle that provides aviability of generating URL address to objects instead of giving route name and route parameters

1.0.3(11y ago)28751[2 PRs](https://github.com/yasiekz/router-bundle/pulls)MITPHP

Since Dec 28Pushed 11y ago1 watchersCompare

[ Source](https://github.com/yasiekz/router-bundle)[ Packagist](https://packagist.org/packages/yasiekz/router-bundle)[ RSS](/packages/yasiekz-router-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (4)Versions (7)Used By (0)

README
======

[](#readme)

[![Build Status](https://camo.githubusercontent.com/e14b8e3b43d9aa74c7ccc317b100085e025cb4c67640d07b19f965c5da622bb5/68747470733a2f2f7472617669732d63692e6f72672f79617369656b7a2f726f757465722d62756e646c652e737667)](https://travis-ci.org/yasiekz/router-bundle)[![Latest Stable Version](https://camo.githubusercontent.com/bf30ba02207f9f97247e32e574eb9ae6a437d2f5eaed554b2e89c9429b59d834/68747470733a2f2f706f7365722e707567782e6f72672f79617369656b7a2f726f757465722d62756e646c652f762f737461626c652e737667)](https://packagist.org/packages/yasiekz/router-bundle)[![Total Downloads](https://camo.githubusercontent.com/8692d85347e60d79e96b4f328a9e6dc61680d6f49752c2f2348ebc85f8c75bac/68747470733a2f2f706f7365722e707567782e6f72672f79617369656b7a2f726f757465722d62756e646c652f646f776e6c6f6164732e737667)](https://packagist.org/packages/yasiekz/router-bundle)[![Latest Unstable Version](https://camo.githubusercontent.com/b15290c4569611748d76978b647fa63a0bde1de957468dd12d4ac8c62d4ba725/68747470733a2f2f706f7365722e707567782e6f72672f79617369656b7a2f726f757465722d62756e646c652f762f756e737461626c652e737667)](https://packagist.org/packages/yasiekz/router-bundle) [![License](https://camo.githubusercontent.com/430470b2eeac894d74ad4b96d7c0fcddc094e1ca6b24bc5b775071031ed7d8d6/68747470733a2f2f706f7365722e707567782e6f72672f79617369656b7a2f726f757465722d62756e646c652f6c6963656e73652e737667)](https://packagist.org/packages/yasiekz/router-bundle)

Bundle that provides aviability of generating URL address to objects instead of giving route name and route parameters

Instalation
-----------

[](#instalation)

Add bundle in your AppKernel.php

```
$bundles = array(
                new Yasiekz\RouterBundle\YasiekzRouterBundle(),
            )

```

Bundle automatically overrides default symfony2 routing service.

Additional Configuration
------------------------

[](#additional-configuration)

There is no additional configuration required.

What interface should I use?
----------------------------

[](#what-interface-should-i-use)

We have two interfaces avaiable. The RoutableCmsInterface is useful when you want to have more than one routing per object for example in CMS systems, where you might want to have diffrent routing for edit, delete object. The RoutableFrontInterface is useful for websites when there is only only one routing per object, but one object might have many routes depends on for example category that object belongs. TheRoutableMultiFrontStrategy is combo of both interfaces.

Usage:
------

[](#usage)

### RoutableCmsInterface

[](#routablecmsinterface)

```
use Yasiekz\RouterBundle\Service\RoutableCmsInterface;

class YourClass implements RoutableCmsIterface
{
    public function getPossibleRoutes()
    {
        // method should return an array of aviable routes as below
        return array(
            'destination1' => 'routingName1',
            'destination2' => 'routingName2'
        );
    }

    public function getRouterParameters($routeName, $destination = null);
    {
        // method should return parameters that is necessary to create routing depend on $destination parameter:
        return array(
            'id' => $this->getId()
        );
    }
}

```

The URL is generated as same as default in Symfony2.

From controller:

```
$object = new YourClass();
$url = $this->generateUrl($object, 'edit');

```

The example above generates indirect address to object $object for destination 'edit'

From twig:

```
{{ path(object, 'edit') }}

```

### RoutableFrontInterface

[](#routablefrontinterface)

Usage

```
use Yasiekz\RouterBundle\Service\RoutableFrontInterface;

class YourClass implements RoutableFrontIterface
{
    public function getRouteName()
    {
        // method should return routeName for given object
        return 'yourclass_detail';
    }

    public function getRouterParameters($routeName, $destination = null);
    {
        // method should return parameters that is necessary to create routing depend on $routeName parameter:

        return array(
            'id' => $this->getId()
        );
    }
}

```

The URL is generated as same as default in symfony2.

From controller:

```
$object = new YourClass();
$paramers = array(); // here might be additional params which be marged to routing
$url = $this->generateUrl($object, $parameters);

```

The example above generates indirect address to object $object without transmission any additional params. Will be taken only params from getRouterParameters() method from class YourClass.

From Twig:

```
{{ path(object, { 'param1': value1, 'param2': value2 }) }}

```

### RoutableMultiFrontInterface

[](#routablemultifrontinterface)

Usage

```
use Yasiekz\RouterBundle\Service\RoutableMultiFrontInterface;

class YourClass implements RoutableMultiFrontInterface
{
    const DESTINATION_ARTICLE = 'article';

    public function getRouteName($parameters = array(), $destination = null)
    {
        // method should return routeName for given object and parameters or destination
        if ($destination == self::DESTINATION_ARTICLE) {
            return 'yourclass_detail';
        }
        return 'yourclass_default';
    }

    public function getRouterParameters($routeName, $destination = null);
    {
        // method should return parameters that is necessary to create routing depend on $routeName parameter:

        return array(
            'id' => $this->getId()
        );
    }
}

```

The URL is generated as same as default in symfony2.

From controller:

```
$object = new YourClass();
$parameters = array('destination' => 'article'); // here might be additional params which be marged to routing
$url = $this->generateUrl($object, $parameters);

```

The example above generates indirect address to object $object with transmission destination param, and merge this param with getRouterParameters() method from class YourClass

From Twig:

```
{{ path(object, { 'destination': 'article', 'param1': value1, 'param2': value2 }) }}

```

Important
---------

[](#important)

There is no possibility that the one class implements all interfaces at the same time.

Contrubution
------------

[](#contrubution)

You are highly encouraged to participate in the development. The terms are the same as the symfony2

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 90.9% 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 ~4 days

Total

4

Last Release

4136d ago

### Community

Maintainers

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

---

Top Contributors

[![yasiekz](https://avatars.githubusercontent.com/u/8867374?v=4)](https://github.com/yasiekz "yasiekz (10 commits)")[![kuczek](https://avatars.githubusercontent.com/u/2432505?v=4)](https://github.com/kuczek "kuczek (1 commits)")

---

Tags

symfonyroutingyasiekz

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M650](/packages/sylius-sylius)[cravler/maxmind-geoip-bundle

Bundle integrating MaxMind GeoIP2 database into symfony application

27615.8k2](/packages/cravler-maxmind-geoip-bundle)[tobion/openapi-symfony-routing

Loads routes in Symfony based on OpenAPI/Swagger annotations

4219.5k](/packages/tobion-openapi-symfony-routing)[ufo-tech/json-rpc-sdk-bundle

The Symfony bundle for simple usage Json-RPC api with dynamic SDK

172.5k](/packages/ufo-tech-json-rpc-sdk-bundle)

PHPackages © 2026

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