wexample / symfony-routing
Various helpers for Symfony routing
Requires
- php: >=8.5
- wexample/symfony-helpers: >=18.0.2
- wexample/symfony-template: >=2.1.2
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-main
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.1
- 2.1.0
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 0.1.8
- 0.1.7
- 0.1.6
- 0.1.5
- 0.1.4
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1.0
- 0.0.21
- 0.0.20
- 0.0.19
- 0.0.17
- 0.0.16
- 0.0.15
- 0.0.14
- 0.0.13
- 0.0.12
- 0.0.11
- 0.0.10
- 0.0.9
- 0.0.8
- 0.0.7
- 0.0.6
- 0.0.5
- 0.0.4
- 0.0.3
This package is auto-updated.
Last update: 2026-10-22 17:07:24 UTC
README
Version: 2.2.2
Various helpers for Symfony routing
Table of Contents
wexample/symfony-routing
Version: 0.0.21
Various helpers for Symfony routing
Table of Contents
Template-based route loader
The bundle ships a Symfony route loader (Wexample\SymfonyDesignSystem\Routing\TemplateBasedRouteLoader) that scans
controllers flagged with the #[TemplateBasedRoutes] attribute and auto-registers routes for each template file
found in the controller directory.
How it works
- Controllers opt-in with the
#[TemplateBasedRoutes]attribute. They usually extendAbstractDesignSystemShowcaseController(which inherits fromAbstractPagesController) and may reuseSymfonyDesignSystemBundleClassTraitto declare the bundle that hosts their templates. - During the container compilation,
TemplateBasedRoutesTagCompilerPassmirrors the attribute into a service tag (has_template_routes). The template loader receives a tagged iterator so it only processes relevant controllers and stays decoupled from the discovery logic. - When the loader runs, it figures out where to look for templates:
- If the controller exposes a bundle via
getDefaultPageBundleClass()(the trait does that), the loader resolves the bundle path and scansResources/views/...for the controller. - Otherwise it falls back to the project root and scans the controller directory under
templates/.
- If the controller exposes a bundle via
- For each Twig template (
*.html.twig) it finds, the loader builds a route name/path using the helpers fromAbstractPagesControllerand wires the route to the controller methodresolveSimpleRoute.
This means that adding a new page is as simple as dropping a Twig file in the controller directory: no manual route declaration is needed, the loader picks it up on the next cache warmup.
Typical setup
#[Route(path: DemoController::CONTROLLER_BASE_ROUTE.'"'"'/demo/'"'"', name: DemoController::CONTROLLER_BASE_ROUTE.'"'"'_demo_'"'"')] #[TemplateBasedRoutes] final class DemoController extends AbstractDesignSystemShowcaseController { use SymfonyDesignSystemBundleClassTrait; // exposes the bundle for template lookup }
# config/routes/design_system.yaml template_routes: resource: . type: template_based_routes
The YAML snippet simply tells Symfony to call our custom loader; it does not affect discovery by itself.
Reusability considerations
The feature currently relies on the abstractions provided by this bundle (AbstractPagesController, bundle traits, etc.). If you need
similar behavior elsewhere, factor those helpers out into a shared library before reusing the loader as-is.
EOF'
Template-based route loader
The bundle ships a Symfony route loader (Wexample\SymfonyDesignSystem\Routing\TemplateBasedRouteLoader) that scans
controllers flagged with the #[TemplateBasedRoutes] attribute and auto-registers routes for each template file
found in the controller directory.
How it works
- Controllers opt-in with the
#[TemplateBasedRoutes]attribute. They usually extendAbstractDesignSystemShowcaseController(which inherits fromAbstractPagesController) and may reuseSymfonyDesignSystemBundleClassTraitto declare the bundle that hosts their templates. - During the container compilation,
TemplateBasedRoutesTagCompilerPassmirrors the attribute into a service tag (has_template_routes). The template loader receives a tagged iterator so it only processes relevant controllers and stays decoupled from the discovery logic. - When the loader runs, it figures out where to look for templates:
- If the controller exposes a bundle via
getDefaultPageBundleClass()(the trait does that), the loader resolves the bundle path and scansResources/views/...for the controller. - Otherwise it falls back to the project root and scans the controller directory under
templates/.
- If the controller exposes a bundle via
- For each Twig template (
*.html.twig) it finds, the loader builds a route name/path using the helpers fromAbstractPagesControllerand wires the route to the controller methodresolveSimpleRoute.
This means that adding a new page is as simple as dropping a Twig file in the controller directory: no manual route declaration is needed, the loader picks it up on the next cache warmup.
Typical setup
#[Route(path: DemoController::CONTROLLER_BASE_ROUTE.'/demo/', name: DemoController::CONTROLLER_BASE_ROUTE.'_demo_')] #[TemplateBasedRoutes] final class DemoController extends AbstractDesignSystemShowcaseController { use SymfonyDesignSystemBundleClassTrait; // exposes the bundle for template lookup }
# config/routes/design_system.yaml template_routes: resource: . type: template_based_routes
The YAML snippet simply tells Symfony to call our custom loader; it does not affect discovery by itself.
Reusability considerations
The feature currently relies on the abstractions provided by this bundle (AbstractPagesController, bundle traits, etc.). If you need
similar behavior elsewhere, factor those helpers out into a shared library before reusing the loader as-is.