AltoRouter
class AltoRouter
Properties
| protected array | $routes | ||
| protected array | $namedRoutes | ||
| protected string | $basePath | ||
| protected array | $matchTypes |
Methods
Create router in one call from config.
Retrieves all routes.
Add multiple routes at once from array in the following format:
Set the base path.
Add named match types. It uses array_merge so keys can be overwritten.
Map a route to a target
Reversed routing
Match a given Request Url against stored routes
Compile the regex for a given route (EXPENSIVE)
Details
at line 39
__construct(array $routes = array(), string $basePath = '', array $matchTypes = array())
Create router in one call from config.
at line 50
array
getRoutes()
Retrieves all routes.
Useful if you want to process or display routes.
at line 66
void
addRoutes(array $routes)
Add multiple routes at once from array in the following format:
$routes = array( array($method, $route, $target, $name) );
at line 79
setBasePath($basePath)
Set the base path.
Useful if you are running your application from a subdirectory.
at line 88
addMatchTypes(array $matchTypes)
Add named match types. It uses array_merge so keys can be overwritten.
at line 101
map(string $method, string $route, mixed $target, string $name = null)
Map a route to a target
at line 127
string
generate(string $routeName, array $params = array())
Reversed routing
Generate the URL for a named route. Replace regexes with supplied parameters
at line 172
array|bool
match(string $requestUrl = null, string $requestMethod = null)
Match a given Request Url against stored routes
at line 243
protected
compileRoute($route)
Compile the regex for a given route (EXPENSIVE)