class Route

Route.

Properties

protected array $methods Methods.
protected string $route Route.
protected string|Closure $action Route action.
protected string $name Route name.
protected string $namespace Route action namespace.
protected string $prefix Route prefix.
protected bool $hasTrailingSlash Does the route have a trailing slash?
protected array $patterns Route patterns.
protected array $middleware Middleware.
protected array $constraints Constraints.
protected array $parameters Parameters.

Methods

__construct(array $methods, string $route, string|Closure $action, string|null $name = null)

Constructor.

array
getMethods()

Returns the HTTP methods the route responds to.

string
getRoute()

Returns the route.

string|Closure
getAction()

Returns the route action.

string|null
getName()

Returns the route name.

array
getMiddleware()

Returns the middleware.

array
getConstraints()

Returns the constraints.

setParameters(array $parameters)

Sets the route parameters.

array
getParameters()

Returns all the route parameters.

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

Returns the named parameter value.

namespace(string $namespace)

Sets the route action namespace.

prefix(string $prefix)

Adds a prefix to the route.

patterns(array $patterns)

Sets the custom patterns.

middleware(array|string $middleware)

Adds a set of middleware.

constraint(array|string $constraint)

Adds a set of constraints.

bool
allowsMethod(string $method)

Returns TRUE if the route allows the specified method or FALSE if not.

bool
hasTrailingSlash()

Returns TRUE if the route has a trailing slash and FALSE if not.

string
getRegex()

Returns the regex needed to match the route.

Details

at line 112
__construct(array $methods, string $route, string|Closure $action, string|null $name = null)

Constructor.

Parameters

array $methods Route methods
string $route Route
string|Closure $action Route action
string|null $name Route name

at line 130
array getMethods()

Returns the HTTP methods the route responds to.

Return Value

array

at line 140
string getRoute()

Returns the route.

Return Value

string

at line 150
string|Closure getAction()

Returns the route action.

Return Value

string|Closure

at line 165
string|null getName()

Returns the route name.

Return Value

string|null

at line 175
array getMiddleware()

Returns the middleware.

Return Value

array

at line 185
array getConstraints()

Returns the constraints.

Return Value

array

at line 195
setParameters(array $parameters)

Sets the route parameters.

Parameters

array $parameters Parameters

at line 205
array getParameters()

Returns all the route parameters.

Return Value

array

at line 217
mixed getParameter(string $name, mixed $default = null)

Returns the named parameter value.

Parameters

string $name Parameter name
mixed $default Default value

Return Value

mixed

at line 228
Route namespace(string $namespace)

Sets the route action namespace.

Parameters

string $namespace Route action namespace

Return Value

Route

at line 241
Route prefix(string $prefix)

Adds a prefix to the route.

Parameters

string $prefix Route prefix

Return Value

Route

at line 257
Route patterns(array $patterns)

Sets the custom patterns.

Parameters

array $patterns Array of patterns

Return Value

Route

at line 270
Route middleware(array|string $middleware)

Adds a set of middleware.

Parameters

array|string $middleware Middleware

Return Value

Route

at line 283
Route constraint(array|string $constraint)

Adds a set of constraints.

Parameters

array|string $constraint Constraint

Return Value

Route

at line 296
bool allowsMethod(string $method)

Returns TRUE if the route allows the specified method or FALSE if not.

Parameters

string $method Method

Return Value

bool

at line 306
bool hasTrailingSlash()

Returns TRUE if the route has a trailing slash and FALSE if not.

Return Value

bool

at line 316
string getRegex()

Returns the regex needed to match the route.

Return Value

string