Documentation

Router
in package
implements Registrar, BindingRegistrar Uses Macroable

Interfaces, Classes and Traits

Registrar
BindingRegistrar

Table of Contents

$middlewarePriority  : array<string|int, mixed>
The priority-sorted list of middleware.
$verbs  : array<string|int, mixed>
All of the verbs supported by the router.
$binders  : array<string|int, mixed>
The registered route value binders.
$container  : Container
The IoC container instance.
$current  : Route
The currently dispatched route instance.
$currentRequest  : Request
The request currently being dispatched.
$events  : Dispatcher
The event dispatcher instance.
$groupStack  : array<string|int, mixed>
The route group attribute stack.
$macros  : array<string|int, mixed>
The registered string macros.
$middleware  : array<string|int, mixed>
All of the short-hand keys for middlewares.
$middlewareGroups  : array<string|int, mixed>
All of the middleware groups.
$patterns  : array<string|int, mixed>
The globally available parameter patterns.
$routes  : RouteCollection
The route collection instance.
__call()  : mixed
Dynamically handle calls into the router instance.
__callStatic()  : mixed
Dynamically handle calls to the class.
__construct()  : void
Create a new Router instance.
aliasMiddleware()  : $this
Register a short-hand name for a middleware.
any()  : Route
Register a new route responding to all verbs.
apiResource()  : PendingResourceRegistration
Route an API resource to a controller.
apiResources()  : void
Register an array of API resource controllers.
auth()  : void
Register the typical authentication routes for an application.
bind()  : void
Add a new route parameter binder.
current()  : Route
Get the currently dispatched route instance.
currentRouteAction()  : string|null
Get the current route action.
currentRouteName()  : string|null
Get the current route name.
currentRouteNamed()  : bool
Determine if the current route matches a pattern.
currentRouteUses()  : bool
Determine if the current route action matches a given action.
delete()  : Route
Register a new DELETE route with the router.
dispatch()  : Response|JsonResponse
Dispatch the request to the application.
dispatchToRoute()  : mixed
Dispatch the request to a route and return the response.
fallback()  : Route
Register a new Fallback route with the router.
gatherRouteMiddleware()  : array<string|int, mixed>
Gather the middleware for the given route with resolved class names.
get()  : Route
Register a new GET route with the router.
getBindingCallback()  : Closure|null
Get the binding callback for a given binding.
getCurrentRequest()  : Request
Get the request currently being dispatched.
getCurrentRoute()  : Route
Get the currently dispatched route instance.
getGroupStack()  : array<string|int, mixed>
Get the current group stack for the router.
getLastGroupPrefix()  : string
Get the prefix from the last group on the stack.
getMiddleware()  : array<string|int, mixed>
Get all of the defined middleware short-hand names.
getMiddlewareGroups()  : array<string|int, mixed>
Get all of the defined middleware groups.
getPatterns()  : array<string|int, mixed>
Get the global "where" patterns.
getRoutes()  : RouteCollection
Get the underlying route collection.
group()  : void
Create a route group with shared attributes.
has()  : bool
Check if a route with the given name exists.
hasGroupStack()  : bool
Determine if the router currently has a group stack.
hasMacro()  : bool
Checks if macro is registered.
hasMiddlewareGroup()  : bool
Check if a middlewareGroup with the given name exists.
input()  : mixed
Get a route parameter for the current route.
is()  : bool
Alias for the "currentRouteNamed" method.
macro()  : void
Register a custom macro.
match()  : Route
Register a new route with the given verbs.
matched()  : void
Register a route matched event listener.
mergeWithLastGroup()  : array<string|int, mixed>
Merge the given array with the last group stack.
middlewareGroup()  : $this
Register a group of middleware.
mixin()  : void
Mix another object into the class.
model()  : void
Register a model binder for a wildcard.
options()  : Route
Register a new OPTIONS route with the router.
patch()  : Route
Register a new PATCH route with the router.
pattern()  : void
Set a global where pattern on all routes.
patterns()  : void
Set a group of global where patterns on all routes.
post()  : Route
Register a new POST route with the router.
prepareResponse()  : Response|JsonResponse
Create a response instance from the given value.
prependMiddlewareToGroup()  : $this
Add a middleware to the beginning of a middleware group.
pushMiddlewareToGroup()  : $this
Add a middleware to the end of a middleware group.
put()  : Route
Register a new PUT route with the router.
redirect()  : Route
Create a redirect from one URI to another.
resource()  : PendingResourceRegistration
Route a resource to a controller.
resourceParameters()  : void
Set the global resource parameter mapping.
resources()  : void
Register an array of resource controllers.
resourceVerbs()  : array<string|int, mixed>|null
Get or set the verbs used in the resource URIs.
respondWithRoute()  : mixed
Return the response returned by the given route.
setRoutes()  : void
Set the route collection instance.
singularResourceParameters()  : void
Set the unmapped global resource parameters to singular.
substituteBindings()  : Route
Substitute the route bindings onto the route.
substituteImplicitBindings()  : void
Substitute the implicit Eloquent model bindings for the route.
toResponse()  : Response|JsonResponse
Static version of prepareResponse.
uses()  : bool
Alias for the "currentRouteUses" method.
view()  : Route
Register a new route that returns a view.
actionReferencesController()  : bool
Determine if the action is routing to a controller.
addRoute()  : Route
Add a route to the underlying route collection.
addWhereClausesToRoute()  : Route
Add the necessary where clauses to the route based on its initial registration.
convertToControllerAction()  : array<string|int, mixed>
Add a controller based route action to the action array.
createRoute()  : Route
Create a new route instance.
findRoute()  : Route
Find the route matching a given request.
loadRoutes()  : void
Load the provided routes.
mergeGroupAttributesIntoRoute()  : void
Merge the group stack with the controller action.
newRoute()  : Route
Create a new Route object.
performBinding()  : mixed
Call the binding callback for the given key.
prefix()  : string
Prefix the given URI with the last prefix.
prependGroupNamespace()  : string
Prepend the last group namespace onto the use clause.
runRoute()  : mixed
Return the response for the given route.
runRouteWithinStack()  : mixed
Run the given route within a Stack "onion" instance.
sortMiddleware()  : array<string|int, mixed>
Sort the given middleware by priority.
updateGroupStack()  : void
Update the group stack with the given attributes.

Properties

$middlewarePriority

The priority-sorted list of middleware.

public array<string|int, mixed> $middlewarePriority = []

Forces the listed middleware to always be in the given order.

$verbs

All of the verbs supported by the router.

public static array<string|int, mixed> $verbs = ['GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS']

$binders

The registered route value binders.

protected array<string|int, mixed> $binders = []

$current

The currently dispatched route instance.

protected Route $current

$currentRequest

The request currently being dispatched.

protected Request $currentRequest

$groupStack

The route group attribute stack.

protected array<string|int, mixed> $groupStack = []

$macros

The registered string macros.

protected static array<string|int, mixed> $macros = []

$middleware

All of the short-hand keys for middlewares.

protected array<string|int, mixed> $middleware = []

$middlewareGroups

All of the middleware groups.

protected array<string|int, mixed> $middlewareGroups = []

$patterns

The globally available parameter patterns.

protected array<string|int, mixed> $patterns = []

Methods

__call()

Dynamically handle calls into the router instance.

public __call(string $method, array<string|int, mixed> $parameters) : mixed
Parameters
$method : string
$parameters : array<string|int, mixed>
Return values
mixed

__callStatic()

Dynamically handle calls to the class.

public static __callStatic(string $method, array<string|int, mixed> $parameters) : mixed
Parameters
$method : string
$parameters : array<string|int, mixed>
Tags
throws
BadMethodCallException
Return values
mixed

aliasMiddleware()

Register a short-hand name for a middleware.

public aliasMiddleware(string $name, string $class) : $this
Parameters
$name : string
$class : string
Return values
$this

any()

Register a new route responding to all verbs.

public any(string $uri[, Closure|array<string|int, mixed>|string|null $action = null ]) : Route
Parameters
$uri : string
$action : Closure|array<string|int, mixed>|string|null = null
Return values
Route

apiResource()

Route an API resource to a controller.

public apiResource(string $name, string $controller[, array<string|int, mixed> $options = [] ]) : PendingResourceRegistration
Parameters
$name : string
$controller : string
$options : array<string|int, mixed> = []
Return values
PendingResourceRegistration

apiResources()

Register an array of API resource controllers.

public apiResources(array<string|int, mixed> $resources) : void
Parameters
$resources : array<string|int, mixed>
Return values
void

auth()

Register the typical authentication routes for an application.

public auth() : void
Return values
void

bind()

Add a new route parameter binder.

public bind(string $key, string|callable $binder) : void
Parameters
$key : string
$binder : string|callable
Return values
void

current()

Get the currently dispatched route instance.

public current() : Route
Return values
Route

currentRouteAction()

Get the current route action.

public currentRouteAction() : string|null
Return values
string|null

currentRouteName()

Get the current route name.

public currentRouteName() : string|null
Return values
string|null

currentRouteNamed()

Determine if the current route matches a pattern.

public currentRouteNamed(dynamic ...$patterns) : bool
Parameters
$patterns : dynamic
Return values
bool

currentRouteUses()

Determine if the current route action matches a given action.

public currentRouteUses(string $action) : bool
Parameters
$action : string
Return values
bool

delete()

Register a new DELETE route with the router.

public delete(string $uri[, Closure|array<string|int, mixed>|string|null $action = null ]) : Route
Parameters
$uri : string
$action : Closure|array<string|int, mixed>|string|null = null
Return values
Route

dispatchToRoute()

Dispatch the request to a route and return the response.

public dispatchToRoute(Request $request) : mixed
Parameters
$request : Request
Return values
mixed

fallback()

Register a new Fallback route with the router.

public fallback(Closure|array<string|int, mixed>|string|null $action) : Route
Parameters
$action : Closure|array<string|int, mixed>|string|null
Return values
Route

gatherRouteMiddleware()

Gather the middleware for the given route with resolved class names.

public gatherRouteMiddleware(Route $route) : array<string|int, mixed>
Parameters
$route : Route
Return values
array<string|int, mixed>

get()

Register a new GET route with the router.

public get(string $uri[, Closure|array<string|int, mixed>|string|null $action = null ]) : Route
Parameters
$uri : string
$action : Closure|array<string|int, mixed>|string|null = null
Return values
Route

getBindingCallback()

Get the binding callback for a given binding.

public getBindingCallback(string $key) : Closure|null
Parameters
$key : string
Return values
Closure|null

getCurrentRequest()

Get the request currently being dispatched.

public getCurrentRequest() : Request
Return values
Request

getCurrentRoute()

Get the currently dispatched route instance.

public getCurrentRoute() : Route
Return values
Route

getGroupStack()

Get the current group stack for the router.

public getGroupStack() : array<string|int, mixed>
Return values
array<string|int, mixed>

getLastGroupPrefix()

Get the prefix from the last group on the stack.

public getLastGroupPrefix() : string
Return values
string

getMiddleware()

Get all of the defined middleware short-hand names.

public getMiddleware() : array<string|int, mixed>
Return values
array<string|int, mixed>

getMiddlewareGroups()

Get all of the defined middleware groups.

public getMiddlewareGroups() : array<string|int, mixed>
Return values
array<string|int, mixed>

getPatterns()

Get the global "where" patterns.

public getPatterns() : array<string|int, mixed>
Return values
array<string|int, mixed>

group()

Create a route group with shared attributes.

public group(array<string|int, mixed> $attributes, Closure|string $routes) : void
Parameters
$attributes : array<string|int, mixed>
$routes : Closure|string
Return values
void

has()

Check if a route with the given name exists.

public has(string $name) : bool
Parameters
$name : string
Return values
bool

hasGroupStack()

Determine if the router currently has a group stack.

public hasGroupStack() : bool
Return values
bool

hasMacro()

Checks if macro is registered.

public static hasMacro(string $name) : bool
Parameters
$name : string
Return values
bool

hasMiddlewareGroup()

Check if a middlewareGroup with the given name exists.

public hasMiddlewareGroup(string $name) : bool
Parameters
$name : string
Return values
bool

input()

Get a route parameter for the current route.

public input(string $key[, string $default = null ]) : mixed
Parameters
$key : string
$default : string = null
Return values
mixed

is()

Alias for the "currentRouteNamed" method.

public is(dynamic ...$patterns) : bool
Parameters
$patterns : dynamic
Return values
bool

macro()

Register a custom macro.

public static macro(string $name, object|callable $macro) : void
Parameters
$name : string
$macro : object|callable
Return values
void

match()

Register a new route with the given verbs.

public match(array<string|int, mixed>|string $methods, string $uri[, Closure|array<string|int, mixed>|string|null $action = null ]) : Route
Parameters
$methods : array<string|int, mixed>|string
$uri : string
$action : Closure|array<string|int, mixed>|string|null = null
Return values
Route

matched()

Register a route matched event listener.

public matched(string|callable $callback) : void
Parameters
$callback : string|callable
Return values
void

mergeWithLastGroup()

Merge the given array with the last group stack.

public mergeWithLastGroup(array<string|int, mixed> $new) : array<string|int, mixed>
Parameters
$new : array<string|int, mixed>
Return values
array<string|int, mixed>

middlewareGroup()

Register a group of middleware.

public middlewareGroup(string $name, array<string|int, mixed> $middleware) : $this
Parameters
$name : string
$middleware : array<string|int, mixed>
Return values
$this

mixin()

Mix another object into the class.

public static mixin(object $mixin) : void
Parameters
$mixin : object
Return values
void

model()

Register a model binder for a wildcard.

public model(string $key, string $class[, Closure|null $callback = null ]) : void
Parameters
$key : string
$class : string
$callback : Closure|null = null
Tags
throws
ModelNotFoundException
Return values
void

options()

Register a new OPTIONS route with the router.

public options(string $uri[, Closure|array<string|int, mixed>|string|null $action = null ]) : Route
Parameters
$uri : string
$action : Closure|array<string|int, mixed>|string|null = null
Return values
Route

patch()

Register a new PATCH route with the router.

public patch(string $uri[, Closure|array<string|int, mixed>|string|null $action = null ]) : Route
Parameters
$uri : string
$action : Closure|array<string|int, mixed>|string|null = null
Return values
Route

pattern()

Set a global where pattern on all routes.

public pattern(string $key, string $pattern) : void
Parameters
$key : string
$pattern : string
Return values
void

patterns()

Set a group of global where patterns on all routes.

public patterns(array<string|int, mixed> $patterns) : void
Parameters
$patterns : array<string|int, mixed>
Return values
void

post()

Register a new POST route with the router.

public post(string $uri[, Closure|array<string|int, mixed>|string|null $action = null ]) : Route
Parameters
$uri : string
$action : Closure|array<string|int, mixed>|string|null = null
Return values
Route

prependMiddlewareToGroup()

Add a middleware to the beginning of a middleware group.

public prependMiddlewareToGroup(string $group, string $middleware) : $this

If the middleware is already in the group, it will not be added again.

Parameters
$group : string
$middleware : string
Return values
$this

pushMiddlewareToGroup()

Add a middleware to the end of a middleware group.

public pushMiddlewareToGroup(string $group, string $middleware) : $this

If the middleware is already in the group, it will not be added again.

Parameters
$group : string
$middleware : string
Return values
$this

put()

Register a new PUT route with the router.

public put(string $uri[, Closure|array<string|int, mixed>|string|null $action = null ]) : Route
Parameters
$uri : string
$action : Closure|array<string|int, mixed>|string|null = null
Return values
Route

redirect()

Create a redirect from one URI to another.

public redirect(string $uri, string $destination[, int $status = 301 ]) : Route
Parameters
$uri : string
$destination : string
$status : int = 301
Return values
Route

resource()

Route a resource to a controller.

public resource(string $name, string $controller[, array<string|int, mixed> $options = [] ]) : PendingResourceRegistration
Parameters
$name : string
$controller : string
$options : array<string|int, mixed> = []
Return values
PendingResourceRegistration

resourceParameters()

Set the global resource parameter mapping.

public resourceParameters([array<string|int, mixed> $parameters = [] ]) : void
Parameters
$parameters : array<string|int, mixed> = []
Return values
void

resources()

Register an array of resource controllers.

public resources(array<string|int, mixed> $resources) : void
Parameters
$resources : array<string|int, mixed>
Return values
void

resourceVerbs()

Get or set the verbs used in the resource URIs.

public resourceVerbs([array<string|int, mixed> $verbs = [] ]) : array<string|int, mixed>|null
Parameters
$verbs : array<string|int, mixed> = []
Return values
array<string|int, mixed>|null

respondWithRoute()

Return the response returned by the given route.

public respondWithRoute(string $name) : mixed
Parameters
$name : string
Return values
mixed

singularResourceParameters()

Set the unmapped global resource parameters to singular.

public singularResourceParameters([bool $singular = true ]) : void
Parameters
$singular : bool = true
Return values
void

substituteBindings()

Substitute the route bindings onto the route.

public substituteBindings(Route $route) : Route
Parameters
$route : Route
Return values
Route

substituteImplicitBindings()

Substitute the implicit Eloquent model bindings for the route.

public substituteImplicitBindings(Route $route) : void
Parameters
$route : Route
Return values
void

uses()

Alias for the "currentRouteUses" method.

public uses(array<string|int, mixed> ...$patterns) : bool
Parameters
$patterns : array<string|int, mixed>
Return values
bool

view()

Register a new route that returns a view.

public view(string $uri, string $view[, array<string|int, mixed> $data = [] ]) : Route
Parameters
$uri : string
$view : string
$data : array<string|int, mixed> = []
Return values
Route

actionReferencesController()

Determine if the action is routing to a controller.

protected actionReferencesController(array<string|int, mixed> $action) : bool
Parameters
$action : array<string|int, mixed>
Return values
bool

addRoute()

Add a route to the underlying route collection.

protected addRoute(array<string|int, mixed>|string $methods, string $uri, Closure|array<string|int, mixed>|string|null $action) : Route
Parameters
$methods : array<string|int, mixed>|string
$uri : string
$action : Closure|array<string|int, mixed>|string|null
Return values
Route

addWhereClausesToRoute()

Add the necessary where clauses to the route based on its initial registration.

protected addWhereClausesToRoute(Route $route) : Route
Parameters
$route : Route
Return values
Route

convertToControllerAction()

Add a controller based route action to the action array.

protected convertToControllerAction(array<string|int, mixed>|string $action) : array<string|int, mixed>
Parameters
$action : array<string|int, mixed>|string
Return values
array<string|int, mixed>

createRoute()

Create a new route instance.

protected createRoute(array<string|int, mixed>|string $methods, string $uri, mixed $action) : Route
Parameters
$methods : array<string|int, mixed>|string
$uri : string
$action : mixed
Return values
Route

findRoute()

Find the route matching a given request.

protected findRoute(Request $request) : Route
Parameters
$request : Request
Return values
Route

loadRoutes()

Load the provided routes.

protected loadRoutes(Closure|string $routes) : void
Parameters
$routes : Closure|string
Return values
void

mergeGroupAttributesIntoRoute()

Merge the group stack with the controller action.

protected mergeGroupAttributesIntoRoute(Route $route) : void
Parameters
$route : Route
Return values
void

newRoute()

Create a new Route object.

protected newRoute(array<string|int, mixed>|string $methods, string $uri, mixed $action) : Route
Parameters
$methods : array<string|int, mixed>|string
$uri : string
$action : mixed
Return values
Route

performBinding()

Call the binding callback for the given key.

protected performBinding(string $key, string $value, Route $route) : mixed
Parameters
$key : string
$value : string
$route : Route
Return values
mixed

prefix()

Prefix the given URI with the last prefix.

protected prefix(string $uri) : string
Parameters
$uri : string
Return values
string

prependGroupNamespace()

Prepend the last group namespace onto the use clause.

protected prependGroupNamespace(string $class) : string
Parameters
$class : string
Return values
string

runRoute()

Return the response for the given route.

protected runRoute(Request $request, Route $route) : mixed
Parameters
$request : Request
$route : Route
Return values
mixed

runRouteWithinStack()

Run the given route within a Stack "onion" instance.

protected runRouteWithinStack(Route $route, Request $request) : mixed
Parameters
$route : Route
$request : Request
Return values
mixed

sortMiddleware()

Sort the given middleware by priority.

protected sortMiddleware(Collection $middlewares) : array<string|int, mixed>
Parameters
$middlewares : Collection
Return values
array<string|int, mixed>

updateGroupStack()

Update the group stack with the given attributes.

protected updateGroupStack(array<string|int, mixed> $attributes) : void
Parameters
$attributes : array<string|int, mixed>
Return values
void

Search results