Router
class Router (View source)
Properties
| static protected array | $routes | Route collection. |
|
| protected array | $error_code | Define the functions related to a 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. |
Methods
Router constructor
Configure route singleton instance
Get the instance of router
Set the base route
Set auto CSRF status Note: Disable only you run on test env
Set prefix
Route mapper
Allows to associate a global middleware on a route
Launch a callback function for each HTTP error code.
Get the error codes
Match route de tout type de method
Get the route collection
Retrieve the define special method
Check user define the special method
Set the current path
Details
protected
__construct(string|null $magic_method = null, string $base_route = '', array $middlewares = [])
Router constructor
static Router
configure(string|null $magic_method = null, string $base_route = '', array $middlewares = [])
Configure route singleton instance
static Router|null
getInstance()
Get the instance of router
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
void
setPrefix(string $prefix)
Set prefix
Router
prefix(string $prefix, callable $cb)
Add a prefix on the roads
void
route(array $definition)
Route mapper
Router
middleware(array|string $middlewares)
Allows to associate a global middleware on a route
Route
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.
array
getErrorCodes()
Get the error codes
Route
match(array $methods, string $path, callable|string|array $cb)
Match route de tout type de method
array
getRoutes()
Get the route collection
string
getSpecialMethod()
Retrieve the define special method
bool
hasSpecialMethod()
Check user define the special method
void
setCurrentPath(string $path)
Set the current path