Class Router
Simple router for named routes that can be used with RegExp
Methods summary
public
|
#
__construct( string $name )
|
public static
|
|
public static
|
#
getMatchedName( )
Getter for $matchedRouteName
Getter for $matchedRouteName
|
public
|
|
public
LucidFrame\Core\Router
|
#
add( string $name, string $path, string $to, string $method = 'GET', array|null $patterns = null )
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+')
Returns
|
public
LucidFrame\Core\Router
|
#
map( string $path, string $to, string $method = 'GET', array|null $patterns = null )
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+')
Returns
|
public static
string|boolean
|
#
match( )
Matching the current route to the defined custom routes
Matching the current route to the defined custom routes
Returns
string|boolean The matched route or false if no matched route is found
|
public static
string|null
|
#
getPathByName( string $name )
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
Returns
string|null
|
public static
|
#
clean( )
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
|
Properties summary
protected static
array
|
$routes
The custom routes defined
The custom routes defined
|
|
protected static
string
|
$matchedRouteName
|
|
protected
string
|
$name
The route name that is unique to the mapped path
The route name that is unique to the mapped path
|
|