Router
class Router (View source)
Properties
protected array | $error_code | Define the functions related to an http code executed if this code is up |
|
protected array | $middlewares | Define the global middleware |
|
protected string | $prefix | Define the routing prefix |
|
protected string | $special_method | ||
protected array | $current | Method Http current. |
|
protected bool | $auto_csrf | Define the auto csrf check status. |
|
static protected array | $routes | Route collection. |
Methods
Router constructor
Set the base route
Set auto CSRF status Note: Disable only you run on test env
Allows to associate a global middleware on an route
Route mapper
Launch a callback function for each HTTP error code.
Match route de tout type de method
Retrieve the define special method
Check user define the special method
Get the route collection
Details
protected
__construct(string $method, string|null $magic_method = null, string $base_route = '', array $middlewares = [])
Router constructor
void
setBaseRoute(string $base_route)
Set the base route
void
setAutoCsrf(bool $auto_csrf)
Set auto CSRF status Note: Disable only you run on test env
Router
prefix(string $prefix, callable $cb)
Add a prefix on the roads
Router
middleware(array $middlewares)
Allows to associate a global middleware on an route
void
route(array $definition)
Route mapper
Router
any(string $path, callable|string|array $cb)
Add a route for
GET, POST, DELETE, PUT, OPTIONS, PATCH
Route
get(string $path, callable|string|array $cb)
Add a GET route
Route
post(string $path, callable|string|array $cb)
Add a POST route
Route
delete(string $path, callable|string|array $cb)
Add a DELETE route
Route
put(string $path, callable|string|array $cb)
Add a PUT route
Route
patch(string $path, callable|string|array $cb)
Add a PATCH route
Route
options(string $path, callable|string|array $cb)
Add a OPTIONS route
Router
code(int $code, callable|array|string $cb)
Launch a callback function for each HTTP error code.
When the define code match with response code.
Router
match(array $methods, string $path, callable|string|array $cb)
Match route de tout type de method
protected string
getSpecialMethod()
Retrieve the define special method
protected bool
hasSpecialMethod()
Check user define the special method
array
getRoutes()
Get the route collection