class Routes

Route collection.

Traits

Extendable trait.

Properties

static protected array $_extensions Class extensions. from ExtendableTrait
protected array $groups Route groups.
protected array $routes Registered routes.
protected array $groupedRoutes Routes grouped by request method.
protected array $namedRoutes Named routes.

Methods

static 
addMethod(string $methodName, Closure $closure)

Adds a method to the class.

mixed
__call(string $name, array $arguments)

Executes class extensions.

static mixed
__callStatic(string $name, array $arguments)

Executes class extensions.

array
getRoutes()

Returns the registered routes.

array
getRoutesByMethod(string $method)

Returns the registered routes that accept the request method.

bool
hasNamedRoute(string $name)

Returns TRUE if the named route exists and FALSE if not.

getNamedRoute(string $name)

Returns the named route.

group(array $options, Closure $routes)

Adds a grouped set of routes to the colleciton.

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

Registers a route.

get(string $route, Closure|string $action, string|null $name = null)

Adds a route that responds to GET requests to the collection.

post(string $route, Closure|string $action, string|null $name = null)

Adds a route that responds to POST requests to the collection.

put(string $route, Closure|string $action, string|null $name = null)

Adds a route that responds to PUT requests to the collection.

patch(string $route, Closure|string $action, string|null $name = null)

Adds a route that responds to PATCH requests to the collection.

delete(string $route, Closure|string $action, string|null $name = null)

Adds a route that responds to DELETE requests to the collection.

all(string $route, Closure|string $action, string|null $name = null)

Adds a route that responts to all HTTP methods to the collection.

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

Adds a route that respodns to the chosen HTTP methods to the collection.

Details

in ExtendableTrait at line 33
static addMethod(string $methodName, Closure $closure)

Adds a method to the class.

Parameters

string $methodName Method name
Closure $closure Closure

in ExtendableTrait at line 45
mixed __call(string $name, array $arguments)

Executes class extensions.

Parameters

string $name Method name
array $arguments Method arguments

Return Value

mixed

in ExtendableTrait at line 62
static mixed __callStatic(string $name, array $arguments)

Executes class extensions.

Parameters

string $name Method name
array $arguments Method arguments

Return Value

mixed

at line 57
array getRoutes()

Returns the registered routes.

Return Value

array

at line 68
array getRoutesByMethod(string $method)

Returns the registered routes that accept the request method.

Parameters

string $method Request method

Return Value

array

at line 79
bool hasNamedRoute(string $name)

Returns TRUE if the named route exists and FALSE if not.

Parameters

string $name Route name

Return Value

bool

at line 90
Route getNamedRoute(string $name)

Returns the named route.

Parameters

string $name Route name

Return Value

Route

at line 106
group(array $options, Closure $routes)

Adds a grouped set of routes to the colleciton.

Parameters

array $options Group options
Closure $routes Route closure

at line 124
protected Route registerRoute(array $methods, string $route, Closure|string $action, string|null $name = null)

Registers a route.

Parameters

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

Return Value

Route

at line 162
Route get(string $route, Closure|string $action, string|null $name = null)

Adds a route that responds to GET requests to the collection.

Parameters

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

Return Value

Route

at line 175
Route post(string $route, Closure|string $action, string|null $name = null)

Adds a route that responds to POST requests to the collection.

Parameters

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

Return Value

Route

at line 188
Route put(string $route, Closure|string $action, string|null $name = null)

Adds a route that responds to PUT requests to the collection.

Parameters

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

Return Value

Route

at line 201
Route patch(string $route, Closure|string $action, string|null $name = null)

Adds a route that responds to PATCH requests to the collection.

Parameters

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

Return Value

Route

at line 214
Route delete(string $route, Closure|string $action, string|null $name = null)

Adds a route that responds to DELETE requests to the collection.

Parameters

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

Return Value

Route

at line 227
Route all(string $route, Closure|string $action, string|null $name = null)

Adds a route that responts to all HTTP methods to the collection.

Parameters

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

Return Value

Route

at line 241
Route register(array $methods, string $route, Closure|string $action, string|null $name = null)

Adds a route that respodns to the chosen HTTP methods to the collection.

Parameters

array $methods Array of HTTP methods the route should respond to
string $route Route
Closure|string $action Route action
string|null $name Route name

Return Value

Route