class Route (View source)

Traits

Properties

string $uri The URI pattern the route responds to.
array $methods The HTTP methods the route responds to.
array $action The route action array.
mixed $controller The controller instance.
array $defaults The default values for the route.
array $wheres The regular expression requirements.
array $parameters The array of matched parameters.
array|null $parameterNames The parameter names for the route.
array|null $computedMiddleware The computed gathered middleware.
CompiledRoute $compiled The compiled version of the route.
static array $validators The validators used by the routes.

Methods

array
resolveMethodDependencies(array $parameters, ReflectionFunctionAbstract $reflector)

Resolve the given method's type-hinted dependencies.

void
__construct(array|string $methods, string $uri, Closure|array $action)

Create a new Route instance.

mixed
run()

Run the route action and return the response.

mixed
getController()

Get the controller instance for the route.

bool
matches(Request $request, bool $includingMethod = true)

Determine if the route matches given request.

$this
bind(Request $request)

Bind the route to a given request for execution.

bool
hasParameters()

Determine if the route has parameters.

bool
hasParameter(string $name)

Determine a given parameter exists from the route.

string|object
parameter(string $name, mixed $default = null)

Get a given parameter from the route.

void
setParameter(string $name, mixed $value)

Set a parameter to the given value.

void
forgetParameter(string $name)

Unset a parameter on the route if it is set.

array
parameters()

Get the key / value list of parameters for the route.

array
parametersWithoutNulls()

Get the key / value list of parameters without null values.

array
parameterNames()

Get all of the parameter names for the route.

array
signatureParameters(string|null $subClass = null)

Get the parameters that are listed in the route / controller signature.

$this
defaults(string $key, mixed $value)

Set a default value for the route.

$this
where(array|string $name, string $expression = null)

Set a regular expression requirement on the route.

array
methods()

Get the HTTP verbs the route responds to.

bool
httpOnly()

Determine if the route only responds to HTTP requests.

bool
httpsOnly()

Determine if the route only responds to HTTPS requests.

bool
secure()

Determine if the route only responds to HTTPS requests.

string|null
domain()

Get the domain defined for the route.

string
getPrefix()

Get the prefix of the route instance.

$this
prefix(string $prefix)

Add a prefix to the route URI.

string
uri()

Get the URI associated with the route.

$this
setUri(string $uri)

Set the URI that the route responds to.

string
getName()

Get the name of the route instance.

$this
name(string $name)

Add or change the route name.

$this
uses(Closure|string $action)

Set the handler for the route.

string
getActionName()

Get the action name for the route.

string
getActionMethod()

Get the method name of the route action.

array
getAction()

Get the action array for the route.

$this
setAction(array $action)

Set the action array for the route.

array
gatherMiddleware()

Get all middleware, including the ones from the controller.

$this|array
middleware(array|string|null $middleware = null)

Get or set the middlewares attached to the route.

array
controllerMiddleware()

Get the middleware for the route's controller.

static array
getValidators()

Get the route validators for the instance.

CompiledRoute
getCompiled()

Get the compiled version of the route.

$this
setRouter(Router $router)

Set the router instance on the route.

$this
setContainer(Container $container)

Set the container instance on the route.

void
prepareForSerialization()

Prepare the route instance for serialization.

mixed
__get(string $key)

Dynamically access route parameters.

Details

array resolveMethodDependencies(array $parameters, ReflectionFunctionAbstract $reflector)

Resolve the given method's type-hinted dependencies.

Parameters

array $parameters
ReflectionFunctionAbstract $reflector

Return Value

array

at line line 121
void __construct(array|string $methods, string $uri, Closure|array $action)

Create a new Route instance.

Parameters

array|string $methods
string $uri
Closure|array $action

Return Value

void

at line line 154
mixed run()

Run the route action and return the response.

Return Value

mixed

at line line 212
mixed getController()

Get the controller instance for the route.

Return Value

mixed

at line line 250
bool matches(Request $request, bool $includingMethod = true)

Determine if the route matches given request.

Parameters

Request $request
bool $includingMethod

Return Value

bool

at line line 287
$this bind(Request $request)

Bind the route to a given request for execution.

Parameters

Request $request

Return Value

$this

at line line 302
bool hasParameters()

Determine if the route has parameters.

Return Value

bool

at line line 313
bool hasParameter(string $name)

Determine a given parameter exists from the route.

Parameters

string $name

Return Value

bool

at line line 329
string|object parameter(string $name, mixed $default = null)

Get a given parameter from the route.

Parameters

string $name
mixed $default

Return Value

string|object

at line line 341
void setParameter(string $name, mixed $value)

Set a parameter to the given value.

Parameters

string $name
mixed $value

Return Value

void

at line line 354
void forgetParameter(string $name)

Unset a parameter on the route if it is set.

Parameters

string $name

Return Value

void

at line line 368
array parameters()

Get the key / value list of parameters for the route.

Return Value

array

Exceptions

LogicException

at line line 382
array parametersWithoutNulls()

Get the key / value list of parameters without null values.

Return Value

array

at line line 394
array parameterNames()

Get all of the parameter names for the route.

Return Value

array

at line line 423
array signatureParameters(string|null $subClass = null)

Get the parameters that are listed in the route / controller signature.

Parameters

string|null $subClass

Return Value

array

at line line 435
$this defaults(string $key, mixed $value)

Set a default value for the route.

Parameters

string $key
mixed $value

Return Value

$this

at line line 449
$this where(array|string $name, string $expression = null)

Set a regular expression requirement on the route.

Parameters

array|string $name
string $expression

Return Value

$this

at line line 490
array methods()

Get the HTTP verbs the route responds to.

Return Value

array

at line line 500
bool httpOnly()

Determine if the route only responds to HTTP requests.

Return Value

bool

at line line 510
bool httpsOnly()

Determine if the route only responds to HTTPS requests.

Return Value

bool

at line line 520
bool secure()

Determine if the route only responds to HTTPS requests.

Return Value

bool

at line line 530
string|null domain()

Get the domain defined for the route.

Return Value

string|null

at line line 541
string getPrefix()

Get the prefix of the route instance.

Return Value

string

at line line 552
$this prefix(string $prefix)

Add a prefix to the route URI.

Parameters

string $prefix

Return Value

$this

at line line 566
string uri()

Get the URI associated with the route.

Return Value

string

at line line 577
$this setUri(string $uri)

Set the URI that the route responds to.

Parameters

string $uri

Return Value

$this

at line line 589
string getName()

Get the name of the route instance.

Return Value

string

at line line 600
$this name(string $name)

Add or change the route name.

Parameters

string $name

Return Value

$this

at line line 613
$this uses(Closure|string $action)

Set the handler for the route.

Parameters

Closure|string $action

Return Value

$this

at line line 645
string getActionName()

Get the action name for the route.

Return Value

string

at line line 655
string getActionMethod()

Get the method name of the route action.

Return Value

string

at line line 665
array getAction()

Get the action array for the route.

Return Value

array

at line line 676
$this setAction(array $action)

Set the action array for the route.

Parameters

array $action

Return Value

$this

at line line 688
array gatherMiddleware()

Get all middleware, including the ones from the controller.

Return Value

array

at line line 707
$this|array middleware(array|string|null $middleware = null)

Get or set the middlewares attached to the route.

Parameters

array|string|null $middleware

Return Value

$this|array

at line line 729
array controllerMiddleware()

Get the middleware for the route's controller.

Return Value

array

at line line 745
static array getValidators()

Get the route validators for the instance.

Return Value

array

at line line 765
CompiledRoute getCompiled()

Get the compiled version of the route.

Return Value

CompiledRoute

at line line 776
$this setRouter(Router $router)

Set the router instance on the route.

Parameters

Router $router

Return Value

$this

at line line 789
$this setContainer(Container $container)

Set the container instance on the route.

Parameters

Container $container

Return Value

$this

at line line 803
void prepareForSerialization()

Prepare the route instance for serialization.

Return Value

void

Exceptions

LogicException

at line line 820
mixed __get(string $key)

Dynamically access route parameters.

Parameters

string $key

Return Value

mixed