PHPackages                             secit-pl/route-injector-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. secit-pl/route-injector-bundle

ActiveSymfony-bundle

secit-pl/route-injector-bundle
==============================

Route Injector Symfony Bundle.

2.0.1(2y ago)12.4kMITPHPPHP &gt;=7.2

Since Dec 29Pushed 2y agoCompare

[ Source](https://github.com/secit-pl/route-injector-bundle)[ Packagist](https://packagist.org/packages/secit-pl/route-injector-bundle)[ Docs](http://secit.pl)[ RSS](/packages/secit-pl-route-injector-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (7)Used By (0)

Route injector annotation
=========================

[](#route-injector-annotation)

Route injector annotation for Symfony 4.0+.

For Symfony 2.8 and 3.x please use the 1.x releases.

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

[](#installation)

From the command line run

```
$ composer require secit-pl/route-injector-bundle

```

Usage
-----

[](#usage)

### The Annotation

[](#the-annotation)

To inject route to the variable just add the @InjectRoute annotation to it. The the first argument is the route name. The second and other arguments are the optional configuration options.

```
use SecIT\RouteInjectorBundle\Mapping\Annotation\InjectRoute;

/**
 * @InjectRoute("route_name", configuration options...);
 */
private $url;
```

### Basic Usage

[](#basic-usage)

Here is the basic usage example.

The class:

```
use SecIT\RouteInjectorBundle\Mapping\Annotation\InjectRoute;

class Example
{
    /**
     * @var string
     *
     * @InjectRoute("route_name", parametersMapping={"param": "getRouteParam"});
     */
    private $url;

    private $routeParam = '';

    /**
     * @return string
     */
    public function getUrl()
    {
        return $this->url;
    }

    /**
     * @return string
     */
    public function getRouteParam()
    {
        return $this->routeParam;
    }

    /**
     * @param string $value
     */
    public function setRouteParam($value)
    {
        $this->routeParam = $value;
    }
}
```

And how to manually run the injector.

```
$processor = $this->container->get('secit.route_injector.processor');
$exampleEbject = new Example();
$exampleEbject->setRouteParam('test');
$processor->injectRoutes($exampleEbject);
```

### Doctrine Entity Usage

[](#doctrine-entity-usage)

This bundle provides the Doctrine integration. So if you use the @InjectRoute annotation in the entity the injectRoutes processor method will be triggered on every (depending on the conditions) load, update and persist action.

Example entity:

```
namespace ExampleBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use SecIT\RouteInjectorBundle\Mapping\Annotation\InjectRoute;

/**
 * @ORM\Table(name="example")
 * @ORM\Entity()
 */
class Example
{
    /**
     * @var string
     *
     * @ORM\Column(name="param", type="string")
     */
    private $param;

    /**
     * @var string
     *
     * @InjectRoute("route_name", parametersMapping={"param": "getParam"});
     */
    private $url;

    /**
     * @return string
     */
    public function getParam()
    {
        return $this->string;
    }

    /**
     * @param string $param
     */
    public function setParam($param)
    {
        $this->string = $param;
    }

    /**
     * @return string
     */
    public function getUrl()
    {
        return $this->url;
    }
}
```

When you create a new Example entity instance the $url will be null. But just after persist the route will be automatically injected and accessible.

```
$exampleObject = new ExampleBundle\Entity\Example();

$this->getDoctrine()->getManager()->persist($exampleObject);
```

### Materialized Routes

[](#materialized-routes)

In the previous example the route will be injected on each time we will load, update or store the entity but in some cases we would like to store it in the database. To achieve this simply add the Doctrine @Column annotation to make it a database field.

```
namespace ExampleBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use SecIT\RouteInjectorBundle\Mapping\Annotation\InjectRoute;

/**
 * @ORM\Table(name="example")
 * @ORM\Entity()
 */
class Example
{
    ...

    /**
     * @var string
     *
     * @ORM\Column(name="url", type="string", length=255)
     * @InjectRoute("route_name", parametersMapping={"param": "getParam"});
     */
    private $url;

    ...
}
```

Configuration options
---------------------

[](#configuration-options)

Here are all possible configuration options:

```
@InjectRoute("route_name", configuration options...);
```

##### parametersMapping = array, default empty array

[](#parametersmapping--array-default-empty-array)

The array of the route parameters mapped to the public class methods from which the parameters values should be taken.

```
@InjectRoute("route_name", parametersMapping={"param": "publicGetterMethodName"});
```

**Warning!** The route will not be injected if any of the parameters will be null.

##### absolute = bool, default false

[](#absolute--bool-default-false)

Set to true if you'd like to have the generated URLs with the protocol and hostname prefix.

```
@InjectRoute("route_name", absolute=true);
```

##### injectIfNotEmpty = bool, default false

[](#injectifnotempty--bool-default-false)

By default the route will be injected only if the current value is empty (null, false, or the empty string). To make it updatable even if it's not empty set this option to true.

```
@InjectRoute("route_name", injectIfNotEmpty=true);
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity62

Established project with proven stability

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

Recently: every ~608 days

Total

6

Last Release

983d ago

Major Versions

1.0.3 → 2.0.02019-11-22

PHP version history (2 changes)1.0.0PHP &gt;=5.4.0

2.0.0PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/16771e4f1b72d12f981ed61b585a74501530faf699086fb30b26ef6117399227?d=identicon)[secit](/maintainers/secit)

---

Top Contributors

[![secit-pl](https://avatars.githubusercontent.com/u/24696884?v=4)](https://github.com/secit-pl "secit-pl (14 commits)")

---

Tags

symfonybundleroute

### Embed Badge

![Health badge](/badges/secit-pl-route-injector-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/secit-pl-route-injector-bundle/health.svg)](https://phpackages.com/packages/secit-pl-route-injector-bundle)
```

###  Alternatives

[pentatrion/vite-bundle

Vite integration for your Symfony app

2725.3M13](/packages/pentatrion-vite-bundle)[web-auth/webauthn-framework

FIDO2/Webauthn library for PHP and Symfony Bundle.

50570.7k1](/packages/web-auth-webauthn-framework)[web-auth/webauthn-symfony-bundle

FIDO2/Webauthn Security Bundle For Symfony

63397.4k6](/packages/web-auth-webauthn-symfony-bundle)[isometriks/spam-bundle

Provides spam protection for Symfony forms

46200.6k1](/packages/isometriks-spam-bundle)[incenteev/hashed-asset-bundle

Apply an asset version based on a hash of the asset for symfony/asset

25526.7k1](/packages/incenteev-hashed-asset-bundle)

PHPackages © 2026

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