symfony-cmf/routing-bundle
Symfony CMF Routing Bundle adds advanced, dynamic routing to Symfony using a content repository. Supports route documents, redirects, nested routes, locale-aware patterns, and custom route providers to manage URLs from CMS content or databases.
symfony-cmf/routing-bundle is a strong fit for applications requiring dynamic route resolution (e.g., CMS-driven sites, multi-tenancy, or content-heavy platforms). It extends Symfony’s router with:
HttpKernel or Routing components, limiting adoption in non-Symfony PHP stacks (e.g., Lumen, Slim). Would need abstraction layers or custom adapters.RouteCache or DoctrineCache).DoctrineRouteProvider, YamlRouteProvider).5.4+ or 6.x (check compatibility with your version).RouterInterface or RouteProviderInterface for bespoke data sources (e.g., API-driven routes).ROUTE_COLLECTOR) for pre/post-routing logic.symfony/var-dumper for debugging).Router in a facade).UrlGenerator) relies on Symfony’s internals.api-platform/core).symfony/routing + custom logic) suffice?6.x that affect this bundle?AppCache) sufficient, or needed custom solutions?api-platform/core (for API-driven routing) or nelmio/api-doc-bundle (if OpenAPI is a priority).fast-route or aura.router for lightweight alternatives.symfony/routing (for static routes).symfony/cache (for route caching).doctrine/orm (if using database-backed routes).# composer.json
{
"require": {
"symfony/cmf/routing-bundle": "^3.0",
"symfony/doctrine-bridge": "^6.0",
"symfony/cache": "^6.0"
}
}
HttpKernel as a micro-service (e.g., via symfony/http-client).RouteResolverInterface) to decouple from Symfony.fast-route or aura.router for simpler needs.routes.yaml, annotations, or attributes).ChainRouter with:
StaticRouter (for existing routes).DoctrineRouter (for database routes).php bin/console debug:router.RouteCache with file or apcu adapter).ChainRouter to fall back to static routes if dynamic routes fail (e.g., during DB outages).6.2). Check for deprecations in symfony/routing or symfony/http-kernel.DoctrineRouteProvider, ensure your Doctrine setup matches the bundle’s expectations (e.g., route entity structure).RouteProviderInterface for unsupported data sources (e.g., Elasticsearch, GraphQL).class ElasticsearchRouteProvider implements RouteProviderInterface {
public function loadRoutes(): array {
// Fetch routes from Elasticsearch
return $this->client->search(...);
}
}
route_cache in config/packages/cmf_routing.yaml:
cmf_routing:
chain_router:
routers_by_id:
dynamic: dynamic_router
static: static_router
dynamic_router:
persistence:
doctrine: ~
cache_pool: app.cache.route
config/packages/cmf_routing.yaml.doctrine or custom).routes.yaml/attributes to the static_router.RouteProvider for your data source (e.g., database migration for route entities).php bin/console cmf:routing:dump.ChainRouter to prioritize dynamic routes (or vice versa).php bin/console debug:router.Monolog subscriber).6.3 breaking changes).php bin/console cache:clear) or via events (e.g., ROUTE_COLLECTOR).ROUTER_DEBUG environment variable or DebugRouter for troubleshooting.How can I help you explore Laravel packages today?