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, string|Closure $action, string|null $name = null)

Registers a route.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Details

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

Adds a method to the class.

Parameters

string $methodName Method name
Closure $closure Closure

in ExtendableTrait at line 47
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 64
static mixed __callStatic(string $name, array $arguments)

Executes class extensions.

Parameters

string $name Method name
array $arguments Method arguments

Return Value

mixed

at line 59
array getRoutes()

Returns the registered routes.

Return Value

array

at line 70
array getRoutesByMethod(string $method)

Returns the registered routes that accept the request method.

Parameters

string $method Request method

Return Value

array

at line 81
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 92
Route getNamedRoute(string $name)

Returns the named route.

Parameters

string $name Route name

Return Value

Route

at line 108
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 126
protected Route registerRoute(array $methods, string $route, string|Closure $action, string|null $name = null)

Registers a route.

Parameters

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

Return Value

Route

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

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

Parameters

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

Return Value

Route

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

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

Parameters

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

Return Value

Route

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

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

Parameters

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

Return Value

Route

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

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

Parameters

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

Return Value

Route

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

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

Parameters

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

Return Value

Route

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

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

Parameters

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

Return Value

Route

at line 243
Route register(array $methods, string $route, string|Closure $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
string|Closure $action Route action
string|null $name Route name

Return Value

Route