RouteCollection

class RouteCollection extends AbstractRouteCollection (View source)

Properties

protected array $routes An array of the routes keyed by method.
protected Route[] $allRoutes A flattened array of all of the routes.
protected Route[] $nameList A look-up table of routes by their names.
protected Route[] $actionList A look-up table of routes by controller action.

Methods

Route handleMatchedRoute(Request $request, Route|null $route)

Handle the matched route.

from AbstractRouteCollection
array checkForAlternateVerbs(Request $request)

Determine if any routes match on another HTTP verb.

from AbstractRouteCollection
Route|null matchAgainstRoutes(array $routes, Request $request, bool $includingMethod = true)

Determine if a route in the array matches the request.

from AbstractRouteCollection
Route getRouteForMethods(Request $request, array $methods)

Get a route (if necessary) that responds when other available methods are present.

from AbstractRouteCollection
void methodNotAllowed(array $others, string $method)

Throw a method not allowed HTTP exception.

from AbstractRouteCollection
array compile()

Compile the routes for caching.

from AbstractRouteCollection
CompiledUrlMatcherDumper dumper()

Return the CompiledUrlMatcherDumper instance for the route collection.

from AbstractRouteCollection
RouteCollection toSymfonyRouteCollection()

Convert the collection to a Symfony RouteCollection instance.

RouteCollection addToSymfonyRoutesCollection(RouteCollection $symfonyRoutes, Route $route)

Add a route to the SymfonyRouteCollection instance.

from AbstractRouteCollection
string generateRouteName()

Get a randomly generated route name.

from AbstractRouteCollection
ArrayIterator getIterator()

Get an iterator for the items.

from AbstractRouteCollection
int count()

Count the number of items in the collection.

from AbstractRouteCollection
Route add(Route $route)

Add a Route instance to the collection.

void addToCollections(Route $route)

Add the given route to the arrays of routes.

void addLookups(Route $route)

Add the route to any look-up tables if necessary.

void addToActionList(array $action, Route $route)

Add a route to the controller action dictionary.

void refreshNameLookups()

Refresh the name look-up table.

void refreshActionLookups()

Refresh the action look-up table.

Route match(Request $request)

Find the first route matching a given request.

Route[] get(string|null $method = null)

Get routes from the collection by method.

bool hasNamedRoute(string $name)

Determine if the route collection contains a given named route.

Route|null getByName(string $name)

Get a route instance by its name.

Route|null getByAction(string $action)

Get a route instance by its controller action.

Route[] getRoutes()

Get all of the routes in the collection.

array getRoutesByMethod()

Get all of the routes keyed by their HTTP verb / method.

Route[] getRoutesByName()

Get all of the routes keyed by their name.

CompiledRouteCollection toCompiledRouteCollection(Router $router, Container $container)

Convert the collection to a CompiledRouteCollection instance.

Details

protected Route handleMatchedRoute(Request $request, Route|null $route)

Handle the matched route.

Parameters

Request $request
Route|null $route

Return Value

Route

Exceptions

NotFoundHttpException

protected array checkForAlternateVerbs(Request $request)

Determine if any routes match on another HTTP verb.

Parameters

Request $request

Return Value

array

protected Route|null matchAgainstRoutes(array $routes, Request $request, bool $includingMethod = true)

Determine if a route in the array matches the request.

Parameters

array $routes
Request $request
bool $includingMethod

Return Value

Route|null

protected Route getRouteForMethods(Request $request, array $methods)

Get a route (if necessary) that responds when other available methods are present.

Parameters

Request $request
array $methods

Return Value

Route

Exceptions

MethodNotAllowedHttpException

protected void methodNotAllowed(array $others, string $method)

Throw a method not allowed HTTP exception.

Parameters

array $others
string $method

Return Value

void

Exceptions

MethodNotAllowedHttpException

array compile()

Compile the routes for caching.

Return Value

array

CompiledUrlMatcherDumper dumper()

Return the CompiledUrlMatcherDumper instance for the route collection.

Return Value

CompiledUrlMatcherDumper

RouteCollection toSymfonyRouteCollection()

Convert the collection to a Symfony RouteCollection instance.

Return Value

RouteCollection

protected RouteCollection addToSymfonyRoutesCollection(RouteCollection $symfonyRoutes, Route $route)

Add a route to the SymfonyRouteCollection instance.

Parameters

RouteCollection $symfonyRoutes
Route $route

Return Value

RouteCollection

protected string generateRouteName()

Get a randomly generated route name.

Return Value

string

ArrayIterator getIterator()

Get an iterator for the items.

Return Value

ArrayIterator

int count()

Count the number of items in the collection.

Return Value

int

Route add(Route $route)

Add a Route instance to the collection.

Parameters

Route $route

Return Value

Route

protected void addToCollections(Route $route)

Add the given route to the arrays of routes.

Parameters

Route $route

Return Value

void

protected void addLookups(Route $route)

Add the route to any look-up tables if necessary.

Parameters

Route $route

Return Value

void

protected void addToActionList(array $action, Route $route)

Add a route to the controller action dictionary.

Parameters

array $action
Route $route

Return Value

void

void refreshNameLookups()

Refresh the name look-up table.

This is done in case any names are fluently defined or if routes are overwritten.

Return Value

void

void refreshActionLookups()

Refresh the action look-up table.

This is done in case any actions are overwritten with new controllers.

Return Value

void

Route match(Request $request)

Find the first route matching a given request.

Parameters

Request $request

Return Value

Route

Exceptions

MethodNotAllowedHttpException
NotFoundHttpException

Route[] get(string|null $method = null)

Get routes from the collection by method.

Parameters

string|null $method

Return Value

Route[]

bool hasNamedRoute(string $name)

Determine if the route collection contains a given named route.

Parameters

string $name

Return Value

bool

Route|null getByName(string $name)

Get a route instance by its name.

Parameters

string $name

Return Value

Route|null

Route|null getByAction(string $action)

Get a route instance by its controller action.

Parameters

string $action

Return Value

Route|null

Route[] getRoutes()

Get all of the routes in the collection.

Return Value

Route[]

array getRoutesByMethod()

Get all of the routes keyed by their HTTP verb / method.

Return Value

array

Route[] getRoutesByName()

Get all of the routes keyed by their name.

Return Value

Route[]

CompiledRouteCollection toCompiledRouteCollection(Router $router, Container $container)

Convert the collection to a CompiledRouteCollection instance.

Parameters

Router $router
Container $container

Return Value

CompiledRouteCollection

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/7.x/Illuminate/Routing/RouteCollection.html