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