Router
class Router implements Registrar (View source)
Traits
Properties
static array | $verbs | All of the verbs supported by the router. |
Methods
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Register an array of controllers with wildcard routing.
Route a controller to a URI with wildcard routing.
Set the unmapped global resource parameters to singular.
Set the global resource parameter mapping.
Register an array of resource controllers.
Route a resource to a controller.
Register the typical authentication routes for an application.
Merge the given array with the last group stack.
Merge the given group attributes.
Get the prefix from the last group on the stack.
Resolve the middleware name to a class name(s) preserving passed parameters.
Register a route matched event listener.
Get all of the defined middleware short-hand names.
Register a short-hand name for a middleware.
Register a group of middleware.
Add a middleware to the beginning of a middleware group.
Add a middleware to the end of a middleware group.
Add a new route parameter binder.
Create a class based binding using the IoC container.
Set a global where pattern on all routes.
Set a group of global where patterns on all routes.
Create a response instance from the given value.
Determine if the router currently has a group stack.
Get the current group stack for the router.
Get a route parameter for the current route.
Get the currently dispatched route instance.
Check if a route with the given name exists.
Get the current route name.
Alias for the "currentRouteName" method.
Determine if the current route matches a given name.
Get the current route action.
Alias for the "currentRouteUses" method.
Determine if the current route action matches a given action.
Get the request currently being dispatched.
Get the underlying route collection.
Get the global "where" patterns.
Details
static
mixed
__callStatic(
string $method,
array $parameters)
Dynamically handle calls to the class.
at line line 109
void
__construct(
Dispatcher $events,
Container $container = null)
Create a new Router instance.
at line line 127
void
get(
string $uri,
Closure|array|string $action = null)
Register a new GET route with the router.
at line line 139
void
post(
string $uri,
Closure|array|string $action = null)
Register a new POST route with the router.
at line line 151
void
put(
string $uri,
Closure|array|string $action = null)
Register a new PUT route with the router.
at line line 163
void
patch(
string $uri,
Closure|array|string $action = null)
Register a new PATCH route with the router.
at line line 175
void
delete(
string $uri,
Closure|array|string $action = null)
Register a new DELETE route with the router.
at line line 187
void
options(
string $uri,
Closure|array|string $action = null)
Register a new OPTIONS route with the router.
at line line 199
Route
any(
string $uri,
Closure|array|string|null $action = null)
Register a new route responding to all verbs.
at line line 214
void
match(
array|string $methods,
string $uri,
Closure|array|string $action = null)
Register a new route with the given verbs.
at line line 227
void
controllers(
array $controllers)
Register an array of controllers with wildcard routing.
at line line 244
void
controller(
string $uri,
string $controller,
array $names = array())
Route a controller to a URI with wildcard routing.
at line line 314
void
singularResourceParameters()
Set the unmapped global resource parameters to singular.
at line line 325
void
resourceParameters(
array $parameters = array())
Set the global resource parameter mapping.
at line line 351
void
resource(
string $name,
string $controller,
array $options = array())
Route a resource to a controller.
at line line 391
void
group(
array $attributes,
Closure $callback)
Create a route group with shared attributes.
at line line 424
array
mergeWithLastGroup(
array $new)
Merge the given array with the last group stack.
at line line 686
mixed
dispatchToRoute(
Request $request)
Dispatch the request to a route and return the response.
at line line 735
array
gatherRouteMiddlewares(
Route $route)
Gather the middleware for the given route.
at line line 749
string|array
resolveMiddlewareClassName(
string $name)
Resolve the middleware name to a class name(s) preserving passed parameters.
at line line 918
$this
middleware(
string $name,
string $class)
Register a short-hand name for a middleware.
at line line 932
$this
middlewareGroup(
string $name,
array $middleware)
Register a group of middleware.
at line line 948
$this
prependMiddlewareToGroup(
string $group,
string $middleware)
Add a middleware to the beginning of a middleware group.
If the middleware is already in the group, it will not be added again.
at line line 966
$this
pushMiddlewareToGroup(
string $group,
string $middleware)
Add a middleware to the end of a middleware group.
If the middleware is already in the group, it will not be added again.
at line line 985
void
model(
string $key,
string $class,
Closure $callback = null)
Register a model binder for a wildcard.
at line line 1019
void
bind(
string $key,
string|callable $binder)
Add a new route parameter binder.
at line line 1034
Closure
createClassBinding(
string $binding)
Create a class based binding using the IoC container.
at line line 1057
void
pattern(
string $key,
string $pattern)
Set a global where pattern on all routes.
at line line 1068
void
patterns(
array $patterns)
Set a group of global where patterns on all routes.
at line line 1082
Response
prepareResponse(
Request $request,
mixed $response)
Create a response instance from the given value.
at line line 1120
mixed
input(
string $key,
string $default = null)
Get a route parameter for the current route.
at line line 1189
bool
currentRouteNamed(
string $name)
Determine if the current route matches a given name.
at line line 1233
bool
currentRouteUses(
string $action)
Determine if the current route action matches a given action.