CompiledRouteCollection
class CompiledRouteCollection extends AbstractRouteCollection
Properties
| protected array | $compiled | The compiled routes collection. |
|
| protected array | $attributes | An array of the route attributes keyed by name. |
|
| protected RouteCollection|null | $routes | The dynamically added routes that were added after loading the cached, compiled routes. |
|
| protected Router | $router | The router instance used by the route. |
|
| protected Container | $container | The container instance used by the route. |
|
| protected Route> | $cachedRoutesByName | Pre-built Route objects keyed by name for this collection. |
|
| protected null|array<string, null|int> | $compiledPortMap | Port lookup map for compiled routes, keyed by "METHOD domain+uri". |
Methods
Determine if a route in the array matches the request.
Get a route (if necessary) that responds when other available methods are present.
Throw a method not allowed HTTP exception.
Return the CompiledUrlMatcherDumper instance for the route collection.
Convert the collection to a Symfony RouteCollection instance.
Add a route to the SymfonyRouteCollection instance.
Get the route instances that should be pre-warmed.
Create a new CompiledRouteCollection instance.
Ensure a dynamically-added route doesn't conflict with a compiled route on port.
Build the port lookup map from compiled route attributes.
Refresh the name look-up table.
Refresh the action look-up table.
Get routes from the collection by method.
Determine if the route collection contains a given named route.
Get a route instance by its controller action.
Get all of the routes in the collection.
Get all of the routes keyed by their HTTP verb / method.
Get all of the routes keyed by their name.
Details
in
AbstractRouteCollection at line 27
protected Route
handleMatchedRoute(Request $request, Route|null $route)
Handle the matched route.
in
AbstractRouteCollection at line 53
protected array
checkForAlternateVerbs(Request $request)
Determine if any routes match on another HTTP verb.
in
AbstractRouteCollection at line 73
protected Route|null
matchAgainstRoutes(array $routes, Request $request, bool $includingMethod = true)
Determine if a route in the array matches the request.
in
AbstractRouteCollection at line 99
protected Route
getRouteForMethods(Request $request, array $methods)
Get a route (if necessary) that responds when other available methods are present.
in
AbstractRouteCollection at line 115
protected never
requestMethodNotAllowed(Request $request, array $others, string $method)
Throw a method not allowed HTTP exception.
in
AbstractRouteCollection at line 131
array
compile()
Compile the routes for caching.
in
AbstractRouteCollection at line 158
CompiledUrlMatcherDumper
dumper()
Return the CompiledUrlMatcherDumper instance for the route collection.
in
AbstractRouteCollection at line 166
RouteCollection
toSymfonyRouteCollection()
Convert the collection to a Symfony RouteCollection instance.
in
AbstractRouteCollection at line 194
protected RouteCollection
addToSymfonyRoutesCollection(RouteCollection $symfonyRoutes, Route $route)
Add a route to the SymfonyRouteCollection instance.
in
AbstractRouteCollection at line 222
protected string
generateRouteName()
Get a randomly generated route name.
at line 292
array
getWarmableRoutes()
Get the route instances that should be pre-warmed.
Returns the collection's cached Route instances — these are the objects actually used during request matching. Unlike getRoutes() which creates fresh throwaway objects every call.
in
AbstractRouteCollection at line 247
Traversable
getIterator()
Get an iterator for the items.
in
AbstractRouteCollection at line 255
int
count()
Count the number of items in the collection.
at line 65
__construct(array $compiled, array $attributes)
Create a new CompiledRouteCollection instance.
at line 89
protected void
ensureNoCrossPortConflictWithCompiledRoutes(Route $route)
Ensure a dynamically-added route doesn't conflict with a compiled route on port.
at line 114
protected array
buildCompiledPortMap()
Build the port lookup map from compiled route attributes.
at line 134
void
refreshNameLookups()
Refresh the name look-up table.
This is done in case any names are fluently defined or if routes are overwritten.
at line 143
void
refreshActionLookups()
Refresh the action look-up table.
This is done in case any actions are overwritten with new controllers.
at line 162
Route
match(Request $request)
Find the first route matching a given request.
Fresh RequestContext per request for coroutine safety — a shared mutable RequestContext would race under coroutine interleaving. The allocation cost of one small object per request is negligible.
No request duplication needed — trailing slashes are trimmed via rtrim() on the path string and passed to match() directly, avoiding the overhead of cloning the entire Request object. RequestBridge also normalizes trailing slashes for real HTTP requests upstream.
at line 219
array
get(string|null $method = null)
Get routes from the collection by method.
at line 227
bool
hasNamedRoute(string $name)
Determine if the route collection contains a given named route.
at line 237
Route|null
getByName(string $name)
Get a route instance by its name.
Returns cached Route objects for the lifetime of this collection.
at line 250
Route|null
getByAction(string $action)
Get a route instance by its controller action.
at line 272
array
getRoutes()
Get all of the routes in the collection.
at line 308
array
getRoutesByMethod()
Get all of the routes keyed by their HTTP verb / method.
at line 327
array
getRoutesByName()
Get all of the routes keyed by their name.
at line 339
protected Route
newRoute(array $attributes)
Resolve an array of attributes to a Route instance.
at line 369
CompiledRouteCollection
setRouter(Router $router)
Set the router instance on the route.
at line 384
CompiledRouteCollection
setContainer(Container $container)
Set the container instance on the route.
Tests only. Swaps the container reference on the route collection used by the singleton Router; per-request use races across coroutines.