PHP Класс PHPRouter\Router

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

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

Метод Описание
__construct ( PHPRouter\RouteCollection $collection )
generate ( $routeName, array $params = [] ) : string Reverse route a named route
match ( string $requestUrl, string $requestMethod = 'GET' ) : boolean | Route Match given request _url and request method and see if a route has been defined for it If so, return route's target If called multiple times
matchCurrentRequest ( ) Matches the current request against mapped routes
parseConfig ( array $config ) : Router Create routes by array, and return a Router object
setBasePath ( $basePath ) Set the base _url - gets prepended to all route _url's.

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

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

public __construct ( PHPRouter\RouteCollection $collection )
$collection PHPRouter\RouteCollection

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

Reverse route a named route
public generate ( $routeName, array $params = [] ) : string
$routeName
$params array Optional array of parameters to use in URL
Результат string The url to the route

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

Match given request _url and request method and see if a route has been defined for it If so, return route's target If called multiple times
public match ( string $requestUrl, string $requestMethod = 'GET' ) : boolean | Route
$requestUrl string
$requestMethod string
Результат boolean | Route

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

Matches the current request against mapped routes
public matchCurrentRequest ( )

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

Create routes by array, and return a Router object
public static parseConfig ( array $config ) : Router
$config array provide by Config::loadFromFile()
Результат Router

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

Set the base _url - gets prepended to all route _url's.
public setBasePath ( $basePath )
$basePath