trait HasRoutesTrait (View source)

Allow objects to have routes

Methods

getRoutes()

Get registered routes

addRoute(RouteInterface $route)

Add a route

route(string[] $methods, mixed $condition, string|Closure|null $handler = null)

Create and add a new route

group(string|Closure|ConditionInterface $condition, Closure|null $routes = null)

Create and add a route group

get(mixed $condition, string|Closure|null $handler = null)

Create and add a route for the GET and HEAD methods

post(mixed $condition, string|Closure|null $handler = null)

Create and add a route for the POST method

put(mixed $condition, string|Closure|null $handler = null)

Create and add a route for the PUT method

patch(mixed $condition, string|Closure|null $handler = null)

Create and add a route for the PATCH method

delete(mixed $condition, string|Closure|null $handler = null)

Create and add a route for the DELETE method

options(mixed $condition, string|Closure|null $handler = null)

Create and add a route for the OPTIONS method

any(mixed $condition, string|Closure|null $handler = null)

Create and add a route for all supported methods

Details

RouteInterface[] getRoutes()

Get registered routes

Return Value

RouteInterface[]

RouteInterface addRoute(RouteInterface $route)

Add a route

Parameters

RouteInterface $route

Return Value

RouteInterface

RouteInterface route(string[] $methods, mixed $condition, string|Closure|null $handler = null)

Create and add a new route

Parameters

string[] $methods
mixed $condition
string|Closure|null $handler

Return Value

RouteInterface

Exceptions

Exception

RouteInterface group(string|Closure|ConditionInterface $condition, Closure|null $routes = null)

Create and add a route group

Parameters

string|Closure|ConditionInterface $condition
Closure|null $routes

Return Value

RouteInterface

RouteInterface get(mixed $condition, string|Closure|null $handler = null)

Create and add a route for the GET and HEAD methods

Parameters

mixed $condition
string|Closure|null $handler

Return Value

RouteInterface

RouteInterface post(mixed $condition, string|Closure|null $handler = null)

Create and add a route for the POST method

Parameters

mixed $condition
string|Closure|null $handler

Return Value

RouteInterface

RouteInterface put(mixed $condition, string|Closure|null $handler = null)

Create and add a route for the PUT method

Parameters

mixed $condition
string|Closure|null $handler

Return Value

RouteInterface

RouteInterface patch(mixed $condition, string|Closure|null $handler = null)

Create and add a route for the PATCH method

Parameters

mixed $condition
string|Closure|null $handler

Return Value

RouteInterface

RouteInterface delete(mixed $condition, string|Closure|null $handler = null)

Create and add a route for the DELETE method

Parameters

mixed $condition
string|Closure|null $handler

Return Value

RouteInterface

RouteInterface options(mixed $condition, string|Closure|null $handler = null)

Create and add a route for the OPTIONS method

Parameters

mixed $condition
string|Closure|null $handler

Return Value

RouteInterface

RouteInterface any(mixed $condition, string|Closure|null $handler = null)

Create and add a route for all supported methods

Parameters

mixed $condition
string|Closure|null $handler

Return Value

RouteInterface