Route

class Route (View source)

Properties

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

Methods

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

Create a new Route instance.

mixed run()

Run the route action and return the response.

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

Determine if the route matches given request.

void compileRoute()

Compile the route into a Symfony CompiledRoute instance.

array extractOptionalParameters()

Get the optional parameters for the route.

array beforeFilters()

Get the "before" filters for the route.

array afterFilters()

Get the "after" filters for the route.

static array parseFilters(string $filters)

Parse the given filter string.

static array explodeFilters(array|string $filters)

Turn the filters into an array if they aren't already.

static array explodeArrayFilters(array $filters)

Flatten out an array of filter declarations.

static array parseFilter(string $filter)

Parse the given filter into name and parameters.

static array parseParameterFilter(string $filter)

Parse a filter with parameters.

string getParameter(string $name, mixed $default = null)

Get a given parameter from the route.

string 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 compileParameterNames()

Get the parameter names for the route.

$this bind(Request $request)

Bind the route to a given request for execution.

array bindParameters(Request $request)

Extract the parameter list from the request.

array bindPathParameters(Request $request)

Get the parameter matches for the path portion of the URI.

array bindHostParameters(Request $request, array $parameters)

Extract the parameter list from the host part of the request.

array matchToKeys(array $matches)

Combine a set of parameter matches with the route's keys.

array replaceDefaults(array $parameters)

Replace null parameters with their defaults.

array parseAction(callable|array $action)

Parse the route action into a standard array.

Closure findClosure(array $action)

Find the Closure in an action array.

static array getValidators()

Get the route validators for the instance.

$this before(string $filters)

Add before filters to the route.

$this after(string $filters)

Add after filters to the route.

$this addFilters(string $type, string $filters)

Add the given filters to the route by type.

$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 parseWhere(array|string $name, string $expression)

Parse arguments to the where method into an array.

$this whereArray(array $wheres)

Set a list of regular expression requirements on the route.

$this prefix(string $prefix)

Add a prefix to the route URI.

string getPath()

Get the URI associated with the route.

string uri()

Get the URI associated with the route.

array getMethods()

Get the HTTP verbs the route responds to.

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 getUri()

Get the URI that the route responds to.

Route setUri(string $uri)

Set the URI that the route responds to.

string getPrefix()

Get the prefix of the route instance.

string getName()

Get the name of the route instance.

string getActionName()

Get the action name for the route.

array getAction()

Get the action array for the route.

$this setAction(array $action)

Set the action array for the route.

CompiledRoute getCompiled()

Get the compiled version of the route.

Details

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

Create a new Route instance.

Parameters

array $methods
string $uri
Closure|array $action

Return Value

void

mixed run()

Run the route action and return the response.

Return Value

mixed

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

Determine if the route matches given request.

Parameters

Request $request
bool $includingMethod

Return Value

bool

protected void compileRoute()

Compile the route into a Symfony CompiledRoute instance.

Return Value

void

protected array extractOptionalParameters()

Get the optional parameters for the route.

Return Value

array

array beforeFilters()

Get the "before" filters for the route.

Return Value

array

array afterFilters()

Get the "after" filters for the route.

Return Value

array

static array parseFilters(string $filters)

Parse the given filter string.

Parameters

string $filters

Return Value

array

static protected array explodeFilters(array|string $filters)

Turn the filters into an array if they aren't already.

Parameters

array|string $filters

Return Value

array

static protected array explodeArrayFilters(array $filters)

Flatten out an array of filter declarations.

Parameters

array $filters

Return Value

array

static array parseFilter(string $filter)

Parse the given filter into name and parameters.

Parameters

string $filter

Return Value

array

static protected array parseParameterFilter(string $filter)

Parse a filter with parameters.

Parameters

string $filter

Return Value

array

string getParameter(string $name, mixed $default = null)

Get a given parameter from the route.

Parameters

string $name
mixed $default

Return Value

string

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

Get a given parameter from the route.

Parameters

string $name
mixed $default

Return Value

string

void setParameter(string $name, mixed $value)

Set a parameter to the given value.

Parameters

string $name
mixed $value

Return Value

void

void forgetParameter(string $name)

Unset a parameter on the route if it is set.

Parameters

string $name

Return Value

void

array parameters()

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

Return Value

array

Exceptions

LogicException

array parametersWithoutNulls()

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

Return Value

array

array parameterNames()

Get all of the parameter names for the route.

Return Value

array

protected array compileParameterNames()

Get the parameter names for the route.

Return Value

array

$this bind(Request $request)

Bind the route to a given request for execution.

Parameters

Request $request

Return Value

$this

array bindParameters(Request $request)

Extract the parameter list from the request.

Parameters

Request $request

Return Value

array

protected array bindPathParameters(Request $request)

Get the parameter matches for the path portion of the URI.

Parameters

Request $request

Return Value

array

protected array bindHostParameters(Request $request, array $parameters)

Extract the parameter list from the host part of the request.

Parameters

Request $request
array $parameters

Return Value

array

protected array matchToKeys(array $matches)

Combine a set of parameter matches with the route's keys.

Parameters

array $matches

Return Value

array

protected array replaceDefaults(array $parameters)

Replace null parameters with their defaults.

Parameters

array $parameters

Return Value

array

protected array parseAction(callable|array $action)

Parse the route action into a standard array.

Parameters

callable|array $action

Return Value

array

protected Closure findClosure(array $action)

Find the Closure in an action array.

Parameters

array $action

Return Value

Closure

static array getValidators()

Get the route validators for the instance.

Return Value

array

$this before(string $filters)

Add before filters to the route.

Parameters

string $filters

Return Value

$this

$this after(string $filters)

Add after filters to the route.

Parameters

string $filters

Return Value

$this

protected $this addFilters(string $type, string $filters)

Add the given filters to the route by type.

Parameters

string $type
string $filters

Return Value

$this

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

Set a default value for the route.

Parameters

string $key
mixed $value

Return Value

$this

$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

protected array parseWhere(array|string $name, string $expression)

Parse arguments to the where method into an array.

Parameters

array|string $name
string $expression

Return Value

array

protected $this whereArray(array $wheres)

Set a list of regular expression requirements on the route.

Parameters

array $wheres

Return Value

$this

$this prefix(string $prefix)

Add a prefix to the route URI.

Parameters

string $prefix

Return Value

$this

string getPath()

Get the URI associated with the route.

Return Value

string

string uri()

Get the URI associated with the route.

Return Value

string

array getMethods()

Get the HTTP verbs the route responds to.

Return Value

array

array methods()

Get the HTTP verbs the route responds to.

Return Value

array

bool httpOnly()

Determine if the route only responds to HTTP requests.

Return Value

bool

bool httpsOnly()

Determine if the route only responds to HTTPS requests.

Return Value

bool

bool secure()

Determine if the route only responds to HTTPS requests.

Return Value

bool

string|null domain()

Get the domain defined for the route.

Return Value

string|null

string getUri()

Get the URI that the route responds to.

Return Value

string

Route setUri(string $uri)

Set the URI that the route responds to.

Parameters

string $uri

Return Value

Route

string getPrefix()

Get the prefix of the route instance.

Return Value

string

string getName()

Get the name of the route instance.

Return Value

string

string getActionName()

Get the action name for the route.

Return Value

string

array getAction()

Get the action array for the route.

Return Value

array

$this setAction(array $action)

Set the action array for the route.

Parameters

array $action

Return Value

$this

CompiledRoute getCompiled()

Get the compiled version of the route.

Return Value

CompiledRoute

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