PHPackages                             rollerworks/route-autowiring-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. rollerworks/route-autowiring-bundle

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

rollerworks/route-autowiring-bundle
===================================

Easily load (autowire) routes in any part of your routing schema

v1.2.0(6y ago)837.8k31MITPHPPHP ^7.2

Since Mar 28Pushed 6y ago2 watchersCompare

[ Source](https://github.com/rollerworks-graveyard/RouteAutowiringBundle)[ Packagist](https://packagist.org/packages/rollerworks/route-autowiring-bundle)[ RSS](/packages/rollerworks-route-autowiring-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (8)Versions (10)Used By (1)

Rollerworks RouteAutowiringBundle
=================================

[](#rollerworks-routeautowiringbundle)

The RollerworksRouteAutowiringBundle allows to import multiple route collections using an autowiring system.

For example you have BundleA which defines some routes, to use them you need to explicitly import them, but if you remove/disable the bundle the application breaks because it can't find the resource files anymore.

When you automatically enable them you can't keep the prefix consistent. And sometimes you rather don't want to enable all route collections.

### How does it work?

[](#how-does-it-work)

In practice you define your routes as normal, but instead of importing them from a file or service you load them using the autowiring system.

Requirements
------------

[](#requirements)

You need at least PHP 7.2 and the Symfony FrameworkBundle.

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

[](#installation)

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

```
$ php composer.phar require rollerworks/route-autowiring-bundle
```

This command requires you to have Composer installed globally, as explained in the [installation chapter](https://getcomposer.org/doc/00-intro.md)of the Composer documentation.

Basic usage
-----------

[](#basic-usage)

There are two parts to this bundle, registering and loading.

Routing schema's are kept per "routing-slot", which are automatically registered whenever you import a route collection.

### Registering routes for loading

[](#registering-routes-for-loading)

Say you have an `AcmeShopBundle` with the following route collections:

```
# Resources/config/routing/frontend.yml

_products:
    resource: "routing/frontend/products.yml"
    prefix:   /products

_cart:
    resource: "routing/frontend/cart.yml"
    prefix:   /cart
```

```
# Resources/config/routing/backend.yml

_products:
    resource: "routing/backend/products.yml"
    prefix:   /products
```

You can import them using the following snippet:

```
use Rollerworks\Bundle\RouteAutowiringBundle\RouteImporter;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;

class AcmeShopExtension extends Extension
{
    // ...

    public function load(array $configs, ContainerBuilder $container): void
    {
        // ...

        $routeImporter = new RouteImporter($container);
        $routeImporter->addObjectResource($this);
        $routeImporter->import('@AcmeShopBundle/Resources/config/routing/frontend.yml', 'frontend');
        $routeImporter->import('@AcmeShopBundle/Resources/config/routing/backend.yml', 'backend');
    }

    // ...
}
```

The `@AcmeShopBundle/Resources/config/routing/frontend.yml` resource will be imported (*or registered*) in the 'frontend' routing-slot. And the `@AcmeShopBundle/Resources/config/routing/backend.yml`resource will be imported in the 'backend' routing slot.

**Note:**

> Route resources follow the same logic as the Symfony routing system, `@AcmeShopBundle` resolves the to full path of the AcmeShopBundle.
>
> See also: [Including External Routing Resources](https://symfony.com/doc/current/book/routing.html#including-external-routing-resources)

**Tip:** You can import multiple routing resources per slot 👍

```
$routeImporter->import('@AcmeShopBundle/Resources/config/routing/frontend.yml', 'frontend');
$routeImporter->import('@AcmeShopBundle/Resources/config/routing/extra.yml', 'frontend');
```

The import will try to guess the correct resource-type, but for special ones (like a service) you need to provide the type in the third parameter:

```
$routeImporter->import('@AcmeShopBundle/Resources/config/routing/frontend.yml', 'frontend', 'yaml');
```

Import multiple resources to the same slot? Provide a default (for the current instance):

```
$routeImporter = new RouteImporter($container, 'frontend');
$routeImporter->import('@AcmeShopBundle/Resources/config/routing/frontend.yml'); // is imported in the frontend slot
$routeImporter->import('@AcmeShopBundle/Resources/config/routing/backend.yml', 'backend'); // is imported in the backend slot
```

### Resource tracking

[](#resource-tracking)

The routing system is not directly aware of any related classes when registering your route imports (using the `RouteImporter`). Therefor removing a Bundle or changing configuration may not directly reload your routing schema (unless you use the `cache:clear` command).

You need to register the Extension class and any other related class, like your Bundle's `Configuration` class, if changing them may cause a different routing import schema.

To register an object (like the `Extension` class, and its parent(s)) use:

`$routeImporter->addObjectResource($this);`

Or to register a class (and its parent(s)):

`$routeImporter->addObjectClass($this);`

To register any Symfony supported Resource (full path) use:

`$routeImporter->addResource(new FileResource('my-file-file-path.yml'));`

**Note:**

> Resources are only tracked when debugging is enabled.
>
> Imported routes (`->import(...)`) are automatically tracked by the routing system, only classes related to the import registering should be registered for tracking.

### Loading registered routes

[](#loading-registered-routes)

Ones your routes are imported into there routing-slot's it's time to load them into the application's routing schema.

Normally you would use something like this:

```
# app/config/routing.yml

_frontend:
    resource: "frontend.yml"
    prefix:   /

_backend:
    resource: "frontend.yml"
    prefix:   /
```

```
# frontend.yml

_AcmeShop:
    resource: "@AcmeShopBundle/Resources/config/routing/frontend.yml"
```

```
# backend.yml

_AcmeShop:
    resource: "@AcmeShopBundle/Resources/config/routing/backend.yml"
```

But instead you load them using the autowiring loader:

```
# app/config/routing.yml

_frontend:
    resource: "frontend"
    type: rollerworks_autowiring
    prefix:   /

_backend:
    resource: "backend"
    type: rollerworks_autowiring
    prefix: backend/
```

That's it! All the routes that were imported in the 'frontend' and 'backend' slots are now loaded into the applications routing schema.

**But wait, what if there are no routes imported for the slot?**

Then nothing happens, this bundle is designed to make configuration easy. When there are no routes imported for the slot it simple returns an empty Collection, which in practice is never used.

### Third-party import example

[](#third-party-import-example)

As the Symfony routing system allows to load any route resource from a routing file you can actually load a routing-slot from within from another routing-slot.

Say you want to allow others to "extend" your bundle's routing schema:

First import the main parts in the application's routing file:

```
# app/config/routing.yml

_frontend:
    resource: "frontend"
    type: rollerworks_autowiring
    prefix:   /

_backend:
    resource: "frontend"
    type: rollerworks_autowiring
    prefix: backend/
```

In AcmeShopBundle define the following routes, and import them (*extension snippet omitted*).

```
# Resources/config/routing/frontend.yml

_products:
    resource: "routing/frontend/products.yml"
    prefix:   /products

_cart:
    resource: "routing/frontend/cart.yml"
    prefix:   /cart
```

```
# Resources/config/routing/frontend.yml

_products:
    resource: "routing/backend/products.yml"
    prefix:   /products

# Load other routing schema's from the routing-slot
_imports:
    resource: "acme_shop.frontend"
    type: rollerworks_autowiring
```

Others can now easily import there routing schema(s) into the `acme_shop.frontend` routing-slot.

Versioning
----------

[](#versioning)

For transparency and insight into the release cycle, and for striving to maintain backward compatibility, this package is maintained under the Semantic Versioning guidelines as much as possible.

Releases will be numbered with the following format:

`..`

And constructed with the following guidelines:

- Breaking backward compatibility bumps the major (and resets the minor and patch)
- New additions without breaking backward compatibility bumps the minor (and resets the patch)
- Bug fixes and misc changes bumps the patch

For more information on SemVer, please visit .

License
-------

[](#license)

The package is provided under the [MIT license](LICENSE).

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 97.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 ~168 days

Recently: every ~193 days

Total

9

Last Release

2350d ago

Major Versions

v0.2.0 → v1.0.02017-08-24

PHP version history (3 changes)v0.1.0PHP &gt;=5.5

v1.0.0PHP ^5.6 || ^7.0

v1.2.0PHP ^7.2

### Community

Maintainers

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

---

Top Contributors

[![sstok](https://avatars.githubusercontent.com/u/904790?v=4)](https://github.com/sstok "sstok (47 commits)")[![kix](https://avatars.githubusercontent.com/u/345754?v=4)](https://github.com/kix "kix (1 commits)")

---

Tags

autowirebundlephproutingsymfonysymfony-bundle

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rollerworks-route-autowiring-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/rollerworks-route-autowiring-bundle/health.svg)](https://phpackages.com/packages/rollerworks-route-autowiring-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)[sulu/headless-bundle

Bundle that provides controllers and services for using Sulu as headless content management system

55133.7k2](/packages/sulu-headless-bundle)

PHPackages © 2026

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