tourze/symfony-routing-auto-loader-bundle

0.0.1 2025-04-27 09:16 UTC

This package is auto-updated.

Last update: 2025-04-28 03:28:02 UTC


README

Latest Stable Version License

A Symfony bundle for automatically loading custom route collections via tagged services. This bundle allows you to define and register your own route loaders, which will be automatically merged into the application's routing system.

Features

  • Auto-discover and load custom route collections via service tags
  • Supports multiple route loaders
  • Seamless integration with Symfony's routing component
  • Simple interface for defining custom route providers

Installation

Requirements

  • PHP 8.1+
  • Symfony 6.4+

Install via Composer

composer require tourze/symfony-routing-auto-loader-bundle

Quick Start

  1. Define a class implementing RoutingAutoLoaderInterface
use Tourze\RoutingAutoLoaderBundle\Service\RoutingAutoLoaderInterface;
use Symfony\Component\Routing\RouteCollection;

class MyRouteLoader implements RoutingAutoLoaderInterface
{
    public function autoload(): RouteCollection
    {
        $routes = new RouteCollection();
        // add routes ...
        return $routes;
    }
}
  1. Register your loader as a service
# config/services.yaml
services:
    App\Routing\MyRouteLoader:
        tags: ['routing.auto.loader']
  1. Routes will be auto-included in your app

Documentation

  • Implement the RoutingAutoLoaderInterface and tag your service with routing.auto.loader.
  • All tagged services will be called and their routes merged into the main collection.
  • Advanced: You can create multiple loaders for different modules or route groups.

Contribution

Contributions are welcome! Please submit issues or pull requests. Ensure code style and tests pass before submitting.

License

MIT License. See LICENSE for details.

Changelog

See the releases page for changelog and upgrade notes.