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
Add a prefix on the roads
Allows to associate a global middleware on an route
Route mapper
Add a route for
Match route de tout type de method
Retrieve the define special method
Check user define the special method
Get the route collection
Details
protected void
__construct($method, $magic_method = null, $base_route = '', array $middlewares = [])
Router constructor
setBaseRoute(string $base_route)
Set the base route
setAutoCsrf(bool $auto_csrf)
Set auto CSRF status Note: Disable only you run on test env
prefix($prefix, callable $cb)
Add a prefix on the roads
Router
middleware(array $middlewares)
Allows to associate a global middleware on an route
route(array $definition)
Route mapper
any($path, $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 $cb)
Add a OPTIONS route
Router
code(int $code, callable $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