class Router (View source)

The Router class handles the registration and evaluation of routes.

Properties

private $routes The routes array.

Methods

__construct()

The constructor.

get(string $url)

Test a given URL against the registered route patterns and return a matching function.

register(string $route, callable $callable)

Register a new route.

Details

__construct()

The constructor.

get(string $url)

Test a given URL against the registered route patterns and return a matching function.

Note that the routes are testes in order they are stored in the routes array. Therefore it is important that the most generic routes are registered last.

Parameters

string $url

register(string $route, callable $callable)

Register a new route.

Parameters

string $route
callable $callable