classe Router (Voir la source)

Propriétés

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.

Méthodes

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(string $prefix, callable $cb)

Add a prefix on the roads

middleware(array $middlewares)

Allows to associate a global middleware on an route

route(array $definition)

Route mapper

any(string $path, callable|string|array $cb)

Add a route for

get(string $path, callable|string|array $cb)

Add a GET route

post(string $path, callable|string|array $cb)

Add a POST route

delete(string $path, callable|string|array $cb)

Add a DELETE route

put(string $path, callable|string|array $cb)

Add a PUT route

patch(string $path, callable|string|array $cb)

Add a PATCH route

options(string $path, callable $cb)

Add a OPTIONS route

code(int $code, callable $cb)

Launch a callback function for each HTTP error code.

match(array $methods, string $path, callable|string|array $cb)

Match route de tout type de method

string
getSpecialMethod()

Retrieve the define special method

bool
hasSpecialMethod()

Check user define the special method

array
getRoutes()

Get the route collection

Détails

protected void __construct($method, $magic_method = null, $base_route = '', array $middlewares = [])

Router constructor

Paramètres

$method
$magic_method
$base_route
array $middlewares

Valeur de retour

void

setBaseRoute(string $base_route)

Set the base route

Paramètres

string $base_route

setAutoCsrf(bool $auto_csrf)

Set auto CSRF status Note: Disable only you run on test env

Paramètres

bool $auto_csrf

Router prefix(string $prefix, callable $cb)

Add a prefix on the roads

Paramètres

string $prefix
callable $cb

Valeur de retour

Router

Exceptions

Router middleware(array $middlewares)

Allows to associate a global middleware on an route

Paramètres

array $middlewares

Valeur de retour

Router

route(array $definition)

Route mapper

Paramètres

array $definition

Exceptions

RouterException

Router any(string $path, callable|string|array $cb)

Add a route for

GET, POST, DELETE, PUT, OPTIONS, PATCH

Paramètres

string $path
callable|string|array $cb

Valeur de retour

Router

Exceptions

Route get(string $path, callable|string|array $cb)

Add a GET route

Paramètres

string $path
callable|string|array $cb

Valeur de retour

Route

Route post(string $path, callable|string|array $cb)

Add a POST route

Paramètres

string $path
callable|string|array $cb

Valeur de retour

Route

Route delete(string $path, callable|string|array $cb)

Add a DELETE route

Paramètres

string $path
callable|string|array $cb

Valeur de retour

Route

Route put(string $path, callable|string|array $cb)

Add a PUT route

Paramètres

string $path
callable|string|array $cb

Valeur de retour

Route

Route patch(string $path, callable|string|array $cb)

Add a PATCH route

Paramètres

string $path
callable|string|array $cb

Valeur de retour

Route

Route options(string $path, callable $cb)

Add a OPTIONS route

Paramètres

string $path
callable $cb

Valeur de retour

Route

Router code(int $code, callable $cb)

Launch a callback function for each HTTP error code.

When the define code match with response code.

Paramètres

int $code
callable $cb

Valeur de retour

Router

Router match(array $methods, string $path, callable|string|array $cb)

Match route de tout type de method

Paramètres

array $methods
string $path
callable|string|array $cb

Valeur de retour

Router

protected string getSpecialMethod()

Retrieve the define special method

Valeur de retour

string

protected bool hasSpecialMethod()

Check user define the special method

Valeur de retour

bool

array getRoutes()

Get the route collection

Valeur de retour

array