Skip to content

AttributeRouting

Opt-in Routing implementation: builds its RouteCollection + meta by scanning #[Route] attributes on action classes instead of a committed Routing/Generated/ tree.

An app switches to attribute routing by extending this (or using it directly) in place of its own generated-routes subclass. A future routes:compile artifact is expected to supersede the live scan done here for production, with this remaining the always-correct fallback.

class AttributeRouting extends Routing

ExtendsRouting
Since1.0.0
SourceRouting/AttributeRouting.php
MethodDescription
getDiagnostics(): array<Diagnostic>

public function getDiagnostics(): array<Diagnostic>

Returns array``<Diagnostic> — Diagnostics recorded while scanning for routes.

These come from an ancestor and are documented where they are declared.

MethodDeclared inDescription
addRoute()RoutingAdd a route dynamically.
exportRoutes()RoutingExport current routing definition (RouteCollection + meta) so RoutingMiddleware can wire it up for dispatch, and so it can be round-tripped back through importRoutes().
gen()RoutingURL generation.
genSelf()Routing
getBaseHref()RoutingReturn the absolute origin (scheme://host[:port]) without trailing slash.
getBasePath()RoutingReturns the path generated URLs are rooted at.
getMeta()Routing
getRequestContext()RoutingReturns the Symfony request context matching and URL generation run against.
getRoute()RoutingRetrieve a single route meta entry or null.
getRouteCollection()RoutingReturns the Symfony route collection the routing matches and generates against.
importRoutes()RoutingImport an entire RouteCollection + meta array, replacing current state.
initialize()RoutingLegacy initialize() hook – stores Context & parameters and marks initialized.
isEnabled()RoutingIndicates whether routing should be considered enabled (subclasses override).
match()Routing
parseRouteString()Routing
reset()RoutingReset state for worker reuse (FrankenPHP etc).
startup()RoutingLegacy startup() hook.