class Router extends AltoRouter

Properties

protected array $routes from  AltoRouter
protected array $namedRoutes from  AltoRouter
protected string $basePath from  AltoRouter
protected array $matchTypes from  AltoRouter

Methods

__construct($sysconf, $obj_db)

Create router in one call from config.

array
getRoutes()

Retrieves all routes.

void
addRoutes(array $routes)

Add multiple routes at once from array in the following format:

setBasePath($basePath)

Set the base path.

addMatchTypes(array $matchTypes)

Add named match types. It uses array_merge so keys can be overwritten.

map(string $method, string $route, mixed $target, string $name = null)

Map a route to a target

string
generate(string $routeName, array $params = array())

Reversed routing

array|bool
match(string $requestUrl = null, string $requestMethod = null)

Match a given Request Url against stored routes

compileRoute($route)

Compile the regex for a given route (EXPENSIVE)

makeCallable($string)

No description

run()

No description

Details

at line 20
__construct($sysconf, $obj_db)

Create router in one call from config.

Parameters

$sysconf
$obj_db

in AltoRouter at line 50
array getRoutes()

Retrieves all routes.

Useful if you want to process or display routes.

Return Value

array

All routes.

in AltoRouter 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) );

Parameters

array $routes

Return Value

void

Exceptions

Exception

in AltoRouter at line 79
setBasePath($basePath)

Set the base path.

Useful if you are running your application from a subdirectory.

Parameters

$basePath

in AltoRouter at line 88
addMatchTypes(array $matchTypes)

Add named match types. It uses array_merge so keys can be overwritten.

Parameters

array $matchTypes

The key is the name and the value is the regex.

in AltoRouter at line 101
map(string $method, string $route, mixed $target, string $name = null)

Map a route to a target

Parameters

string $method

One of 5 HTTP Methods, or a pipe-separated list of multiple HTTP Methods (GET|POST|PATCH|PUT|DELETE)

string $route

The route regex, custom regex must start with an @. You can use multiple pre-set regex filters, like [i:id]

mixed $target

The target where this route should point to. Can be anything.

string $name

Optional name of this route. Supply if you want to reverse route this url in your application.

Exceptions

Exception

in AltoRouter at line 127
string generate(string $routeName, array $params = array())

Reversed routing

Generate the URL for a named route. Replace regexes with supplied parameters

Parameters

string $routeName

The name of the route.

array $params

Return Value

string

The URL of the route with named parameters in place.

Exceptions

Exception

at line 27
array|bool match(string $requestUrl = null, string $requestMethod = null)

Match a given Request Url against stored routes

Parameters

string $requestUrl
string $requestMethod

Return Value

array|bool

Array with route information on success, false on failure (no match).

in AltoRouter at line 243
protected compileRoute($route)

Compile the regex for a given route (EXPENSIVE)

Parameters

$route

at line 100
makeCallable($string)

No description

Parameters

$string

at line 112
run()

No description