PHP Класс System\Router

Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$actions array Actions to call before and after routes
$method str The current request method
$not_found array | closure Actions to call on not matched routes
$patterns array Array of regex patterns to subsitute in defined routes
$routes array The defined routes set by the app
$uri str The current URI

Открытые методы

Метод Описание
__construct ( $method, $uri ) Create a new instance of the Router class and import app routes from a folder or a single routes.php file
create ( ) : object Create a new instance of the Router class for chaining
dispatch ( ) : object Match the request with a route and run it
match ( ) : object Try and match the request method and uri with defined routes
routes ( ) : array Gets array of request method routes

Описание методов

__construct() публичный Метод

Create a new instance of the Router class and import app routes from a folder or a single routes.php file
public __construct ( $method, $uri )

create() публичный статический Метод

Create a new instance of the Router class for chaining
public static create ( ) : object
Результат object

dispatch() публичный Метод

Match the request with a route and run it
public dispatch ( ) : object
Результат object Response instance

match() публичный Метод

Try and match the request method and uri with defined routes
public match ( ) : object
Результат object Return a instance of a Route

routes() публичный Метод

Gets array of request method routes
public routes ( ) : array
Результат array

Описание свойств

$actions публичное статическое свойство

Actions to call before and after routes
public static array $actions
Результат array

$method публичное свойство

The current request method
public str $method
Результат str

$not_found публичное статическое свойство

Actions to call on not matched routes
public static array|closure $not_found
Результат array | closure

$patterns публичное статическое свойство

Array of regex patterns to subsitute in defined routes
public static array $patterns
Результат array

$routes публичное статическое свойство

The defined routes set by the app
public static array $routes
Результат array

$uri публичное свойство

The current URI
public str $uri
Результат str