PHPackages                             wjb/rewire-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. wjb/rewire-bundle

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

wjb/rewire-bundle
=================

Use objects to generate routes

v1.0.4(7y ago)5102MITPHP

Since Jan 4Pushed 7y ago1 watchersCompare

[ Source](https://github.com/zmitic/rewire-bundle)[ Packagist](https://packagist.org/packages/wjb/rewire-bundle)[ RSS](/packages/wjb-rewire-bundle/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (5)Dependencies (5)Versions (6)Used By (0)

[![SensioLabsInsight](https://camo.githubusercontent.com/fcaebe89131e88d86b927430604adafbcba7300b157ce03a0ac364b66c583203/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f35323162613231312d653236642d343139632d396430642d3933633536393530633162622f6269672e706e67)](https://insight.sensiolabs.com/projects/521ba211-e26d-419c-9d0d-93c56950c1bb)

#### Use objects to generate routes

[](#use-objects-to-generate-routes)

Let's say you have a blog application with route like this:

```
/**
 * @Route("/{id}", name="post_detailed")
 */
public function indexAction(Post $post)
{...}
```

then your templates will have this:

```
View post
```

*For this simple case, [ParamConverter](https://symfony.com/doc/current/best_practices/controllers.html#using-the-paramconverter) is automatically applied.*

##### The problem

[](#the-problem)

Now imagine you want to change it to use `{slug}` instead of `{id}` in your URL. Updating controller is simple, but updating all the templates is not so.

##### The solution

[](#the-solution)

This bundle acts as ReverseParamConverter. Check this example:

```
/**
 * @Route("/{id}", name="post_detailed")
 * @RewireParams(requires={"post"}, rewire={"id"="post.id"})
 */
public function indexAction(Post $post)
{...}
```

and the template:

```
View post
```

Now instead of `new_post.id` you can use object itself and this bundle will use it to generate `{id}` needed for route.

So if you want to slug instead of id in your route, just update your controller:

```
/**
 * @Route("/{slug}", name="post_detailed")
 * @RewireParams(requires={"post"}, rewire={"slug"="post.slug"})
 */
public function indexAction(Post $post)
{...}
```

and that's all, template doesn't require any changes.

#### Note

[](#note)

If you install this bundle, you don't have to change all your templates immediatelly. So both these combinations would still work:

```
View post

View post
```

#### Complex routes

[](#complex-routes)

The above example is pretty simple so let's try something more complex. For this, imagine we wanted to add `{category_slug}` to URL for better SEO.

The old way:

```
/**
 * @Route("/{category_slug}/{slug}", name="post_detailed")
 */
public function indexAction(Post $post)
{...}
```

```
View post
```

For this fictional blog application, generated route would be something like `/conspiracy-theories/why-they-suck`. You can see why updating templates can be a problem.

With this bundle:

```
/**
 * @Route("/{category_slug}/{slug}", name="post_detailed")
 * @RewireParams(requires={"post"}, rewire={"category_slug"="post.category.slug", "slug": post.slug})
 */
public function indexAction(Post $post)
{...}
```

your template doesn't require any changes, it would remain the same:

```
View post
```

#### Usage

[](#usage)

The @RewireParams annotation has 2 properties:

- requires: these are names of your parameters. `post` is used in all examples.
- rewire: a set of key=&gt;value pairs where key is the name used in your @Route annotation and value is [PropertyAccess](http://symfony.com/doc/current/components/property_access.html#reading-from-objects) rule for reading objects.

#### Perfomance

[](#perfomance)

While there is perfomance hit, I didn't notice any on page with 106 routes (largest I have). It is probably too small to spot it but more testing is needed.

Program works by caching @RewireParams annotations and later using it in Router decorator class. Given this bundle is built in a day, I am sure improvements can be made.

#### Installation

[](#installation)

```
composer require wjb/rewire-bundle

```

If you are on Symfony4, you don't have to do anything else. For Symfony3, enable the bundle in your AppKernel:

```
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            ...
            new wjb\RewireBundle\wjbRewireBundle(),
            ...

```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 75% 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 ~35 days

Total

5

Last Release

2912d ago

### Community

Maintainers

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

---

Top Contributors

[![zmitic](https://avatars.githubusercontent.com/u/1964158?v=4)](https://github.com/zmitic "zmitic (18 commits)")[![spx-zeljkomitic](https://avatars.githubusercontent.com/u/34568459?v=4)](https://github.com/spx-zeljkomitic "spx-zeljkomitic (4 commits)")[![kunicmarko20](https://avatars.githubusercontent.com/u/13528674?v=4)](https://github.com/kunicmarko20 "kunicmarko20 (1 commits)")[![vudaltsov](https://avatars.githubusercontent.com/u/2552865?v=4)](https://github.com/vudaltsov "vudaltsov (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/wjb-rewire-bundle/health.svg)

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

###  Alternatives

[sylius/sylius

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

8.4k5.6M651](/packages/sylius-sylius)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

7310.3k29](/packages/open-dxp-opendxp)[chameleon-system/chameleon-base

The Chameleon System core.

1026.5k3](/packages/chameleon-system-chameleon-base)[mapado/rest-client-sdk

Rest Client SDK for hydra API

1125.9k2](/packages/mapado-rest-client-sdk)

PHPackages © 2026

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