class Route

Route.

Properties

protected array $methods Methods.
protected string $route Route.
protected Closure|string $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, Closure|string $action, string|null $name = null)

Constructor.

array
getMethods()

Returns the HTTP methods the route responds to.

string
getRoute()

Returns the route.

Closure|string
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 110
__construct(array $methods, string $route, Closure|string $action, string|null $name = null)

Constructor.

Parameters

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

at line 128
array getMethods()

Returns the HTTP methods the route responds to.

Return Value

array

at line 138
string getRoute()

Returns the route.

Return Value

string

at line 148
Closure|string getAction()

Returns the route action.

Return Value

Closure|string

at line 163
string|null getName()

Returns the route name.

Return Value

string|null

at line 173
array getMiddleware()

Returns the middleware.

Return Value

array

at line 183
array getConstraints()

Returns the constraints.

Return Value

array

at line 193
setParameters(array $parameters)

Sets the route parameters.

Parameters

array $parameters Parameters

at line 203
array getParameters()

Returns all the route parameters.

Return Value

array

at line 215
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 226
Route namespace(string $namespace)

Sets the route action namespace.

Parameters

string $namespace Route action namespace

Return Value

Route

at line 239
Route prefix(string $prefix)

Adds a prefix to the route.

Parameters

string $prefix Route prefix

Return Value

Route

at line 255
Route patterns(array $patterns)

Sets the custom patterns.

Parameters

array $patterns Array of patterns

Return Value

Route

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

Adds a set of middleware.

Parameters

array|string $middleware Middleware

Return Value

Route

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

Adds a set of constraints.

Parameters

array|string $constraint Constraint

Return Value

Route

at line 294
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 304
bool hasTrailingSlash()

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

Return Value

bool

at line 314
string getRegex()

Returns the regex needed to match the route.

Return Value

string