Methods |
public
|
__construct(string $name)
Constructor
|
#
|
public
static
|
getRoutes()
Getter for $routes
|
#
|
public
static
|
getMatchedName()
Getter for $matchedRouteName
Getter for $matchedRouteName
|
#
|
public
|
getName()
Getter for $name
|
#
|
public
static
|
init()
Initialize URL routing
|
#
|
public
static
|
request(): string
Returns the requested URL path of the page being viewed.
Examples:
- http://example.com/foo/bar returns "foo/bar".
Returns the requested URL path of the page being viewed.
Examples:
Returns
|
#
|
public
|
add(string $name, string $path, string $to, string $method = 'GET', array|null $patterns = null): Router
Define the custom routing path
Define the custom routing path
Parameters
$name |
Any unique route name to the mapped $path
|
$path |
URL path with optional dynamic variables such as /post/{id}/edit
|
$to |
The real path to a directory or file in /app
|
$method |
GET, POST, PUT or DELETE or any combination with | such as GET|POST
|
$patterns |
array of the regex patterns for variables in $path such s array('id' => '\d+')
|
|
#
|
public
|
map(string $path, string|Closure $to, string $method = 'GET', array|null $patterns = null): Router
Define the custom routing path
Define the custom routing path
Parameters
$path |
URL path with optional dynamic variables such as /post/{id}/edit
|
$to |
The real path to a directory or file in /app
|
$method |
GET, POST, PUT or DELETE or any combination with | such as GET|POST
|
$patterns |
array of the regex patterns for variables in $path such s array('id' => '\d+')
|
|
#
|
public
static
|
match(): string|Closure|boolean
Matching the current route to the defined custom routes
Matching the current route to the defined custom routes
Returns
The matched route or false if no matched route is found
|
#
|
public
static
|
getPathByName(string $name): string|null
Get the path from the given name
Get the path from the given name
Parameters
$name |
The route name that is unique to the mapped path
|
|
#
|
public
static
|
clean(): void
Delete all defined named routes
Delete all defined named routes
|
#
|
public
static
|
group(string $prefix, callable $callback)
Define route group
Parameters
$prefix |
A prefix for the group of the routes
|
$callback |
The callback function that defines each route in the group
|
|
#
|
public
static
|
getAbsolutePathToRoot(string $q): string
Get the absolute path from root of the given route
Get the absolute path from root of the given route
|
#
|