Documentation

Router extends Component

Table of Contents

$params  : array<string|int, mixed>
Parameters from the matched route.
$routes  : array<string|int, mixed>
Associative array of routes (the routing table).
$request  : array<string|int, mixed>
Parameters from the matched route.
add()  : void
Add a route to the routing table.
addMiddleware()  : object
Add the middleware.
addRoutes()  : void
Add multiple routes at once from array in the following format:.
all()  : void
Add a route to the routing table as all method.
cacheRouters()  : void
Cache the roouter.
connect()  : void
Add a route to the routing table as CONNECT.
delete()  : void
Add a route to the routing table as DELETE.
dispatch()  : void
Dispatch the route, creating the controller object and running the action method.
get()  : void
Add a route to the routing table as GET.
getInput()  : mixed
Get the current input according to given method.
getParams()  : array<string|int, mixed>
Get the currently matched parameters.
getRoutes()  : array<string|int, mixed>
Get all the routes from the routing table.
loadCache()  : array<string|int, mixed>
Load routers form cache.
loadComponents()  : void
Load the components.
match()  : bool
Match the route to the routes in the routing table, setting the $params property if a route is found.
methodMatch()  : bool
Match the request methods.
options()  : void
Add a route to the routing table as OPTIONS.
parseurl()  : string
Parase the url if need.
patch()  : void
Add a route to the routing table as PATCH.
post()  : void
Add a route to the routing table as POST.
put()  : void
Add a route to the routing table as PUT.
redirect()  : void
Add a route to the routing table as Redirect.
trace()  : void
Add a route to the routing table as TRACE.
view()  : void
Add a route to the routing table as view.
convertToCamelCase()  : string
Convert the string with hyphens to camelCase,.
convertToStudlyCaps()  : string
Convert the string with hyphens to StudlyCaps,.
getNamespace()  : string
Get the namespace for the controller class. The namespace defined in the route parameters is added if present.
parseRoutes()  : string
Parse the router.
RemoveQueryString()  : string
Remove the query string variables from the URL (if any). As the full.

Properties

$params

Parameters from the matched route.

protected array<string|int, mixed> $params = []
Tags
since
1.0.0

$routes

Associative array of routes (the routing table).

protected array<string|int, mixed> $routes = []
Tags
since
1.0.0

$request

Parameters from the matched route.

private array<string|int, mixed> $request
Tags
since
1.0.0

Methods

add()

Add a route to the routing table.

public add(string $route[, array<string|int, mixed>|string $params = '' ][, string $methods = 'GET|HEAD' ][, string $middleware = '' ][, array<string|int, mixed> $redirect = [] ][, mixed $view = null ]) : void
Parameters
$route : string

The route URL

$params : array<string|int, mixed>|string = ''

Parameters (controller, action, etc.) or $params Home@index

$methods : string = 'GET|HEAD'

request method like GET or GET|POST

$middleware : string = ''

Middleare name

$redirect : array<string|int, mixed> = []

Redirect

$view : mixed = null

View

Tags
since
1.0.0
Return values
void —

addMiddleware()

Add the middleware.

public addMiddleware((string) $name) : object
Parameters
$name : (string)

name of middleware

Tags
since
1.0.0
Return values
object —

addRoutes()

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

public addRoutes( $routes) : void
Parameters
$routes :

= [route,param,method,middleware]

Tags
since
1.0.0
Return values
void —

all()

Add a route to the routing table as all method.

public all(string $route, array<string|int, mixed>|string $params[, string $middleware = '' ]) : void
Parameters
$route : string

The route URL

$params : array<string|int, mixed>|string

Parameters (controller, action, etc.) or $params Home@index

$middleware : string = ''

Middleare name

Tags
since
1.0.0
Return values
void —

cacheRouters()

Cache the roouter.

public cacheRouters() : void
Tags
since
1.0.0
Return values
void —

connect()

Add a route to the routing table as CONNECT.

public connect(string $route, array<string|int, mixed>|string $params[, string $middleware = '' ]) : void
Parameters
$route : string

The route URL

$params : array<string|int, mixed>|string

Parameters (controller, action, etc.) or $params Home@index

$middleware : string = ''

Middleare name

Tags
since
1.0.0
Return values
void —

delete()

Add a route to the routing table as DELETE.

public delete(string $route, array<string|int, mixed>|string $params[, string $middleware = '' ]) : void
Parameters
$route : string

The route URL

$params : array<string|int, mixed>|string

Parameters (controller, action, etc.) or $params Home@index

$middleware : string = ''

Middleare name

Tags
since
1.0.0
Return values
void —

dispatch()

Dispatch the route, creating the controller object and running the action method.

public dispatch(Request $request) : void
Parameters
$request : Request
Tags
since
1.0.0
Return values
void —

get()

Add a route to the routing table as GET.

public get(string $route, array<string|int, mixed>|string $params[, string $middleware = '' ]) : void
Parameters
$route : string

The route URL

$params : array<string|int, mixed>|string

Parameters (controller, action, etc.) or $params Home@index

$middleware : string = ''

Middleare name

Tags
since
1.0.0
Return values
void —

getInput()

Get the current input according to given method.

public getInput(Input $input) : mixed
Parameters
$input : Input
Tags
since
1.0.0
Return values
mixed —

getParams()

Get the currently matched parameters.

public getParams() : array<string|int, mixed>
Tags
since
1.0.0
Return values
array<string|int, mixed> —

getRoutes()

Get all the routes from the routing table.

public getRoutes() : array<string|int, mixed>
Tags
since
1.0.0
Return values
array<string|int, mixed> —

loadCache()

Load routers form cache.

public loadCache() : array<string|int, mixed>
Tags
since
1.0.0
Return values
array<string|int, mixed> —

loadComponents()

Load the components.

public static loadComponents() : void
Tags
since
1.9.7
Return values
void —

match()

Match the route to the routes in the routing table, setting the $params property if a route is found.

public match(string $url) : bool
Parameters
$url : string

The route URL

Tags
since
1.0.0
Return values
bool —

true if a match found, false otherwise

methodMatch()

Match the request methods.

public methodMatch(string $methods, string $requestMethod, Request $request) : bool
Parameters
$methods : string

router request method

$requestMethod : string

Requested method

$request : Request
Tags
since
1.0.0
Return values
bool —

options()

Add a route to the routing table as OPTIONS.

public options(string $route, array<string|int, mixed>|string $params[, string $middleware = '' ]) : void
Parameters
$route : string

The route URL

$params : array<string|int, mixed>|string

Parameters (controller, action, etc.) or $params Home@index

$middleware : string = ''

Middleare name

Tags
since
1.0.0
Return values
void —

parseurl()

Parase the url if need.

public parseurl() : string
Tags
since
1.0.0
deprecated
3.0.0
Return values
string —

The request URL

patch()

Add a route to the routing table as PATCH.

public patch(string $route, array<string|int, mixed>|string $params[, string $middleware = '' ]) : void
Parameters
$route : string

The route URL

$params : array<string|int, mixed>|string

Parameters (controller, action, etc.) or $params Home@index

$middleware : string = ''

Middleare name

Tags
since
1.0.0
Return values
void —

post()

Add a route to the routing table as POST.

public post(string $route, array<string|int, mixed>|string $params[, string $middleware = '' ]) : void
Parameters
$route : string

The route URL

$params : array<string|int, mixed>|string

Parameters (controller, action, etc.) or $params Home@index

$middleware : string = ''

Middleare name

Tags
since
1.0.0
Return values
void —

put()

Add a route to the routing table as PUT.

public put(string $route, array<string|int, mixed>|string $params[, string $middleware = '' ]) : void
Parameters
$route : string

The route URL

$params : array<string|int, mixed>|string

Parameters (controller, action, etc.) or $params Home@index

$middleware : string = ''

Middleare name

Tags
since
1.0.0
Return values
void —

redirect()

Add a route to the routing table as Redirect.

public redirect(string $route, string $to[, string $code = '301' ]) : void
Parameters
$route : string

The route URL

$to : string

Where you want to redirect

$code : string = '301'

The HTTP code

Tags
since
1.0.0
Return values
void —

trace()

Add a route to the routing table as TRACE.

public trace(string $route, array<string|int, mixed>|string $params[, string $middleware = '' ]) : void
Parameters
$route : string

The route URL

$params : array<string|int, mixed>|string

Parameters (controller, action, etc.) or $params Home@index

$middleware : string = ''

Middleare name

Tags
since
1.0.0
Return values
void —

view()

Add a route to the routing table as view.

public view(string $route, string $view[, array<string|int, mixed> $params = [] ][, mixed $method = 'GET' ][, string $middleware = '' ]) : void
Parameters
$route : string

The route URL

$view : string

View File

$params : array<string|int, mixed> = []

Parameters

$method : mixed = 'GET'
$middleware : string = ''

Middleare name

Tags
since
1.0.0
Return values
void —

convertToCamelCase()

Convert the string with hyphens to camelCase,.

protected convertToCamelCase(string $string) : string
Parameters
$string : string

The string to convert

Tags
since
1.0.0
Return values
string —

convertToStudlyCaps()

Convert the string with hyphens to StudlyCaps,.

protected convertToStudlyCaps(string $string) : string
Parameters
$string : string

The string to convert

Tags
since
1.0.0
Return values
string —

getNamespace()

Get the namespace for the controller class. The namespace defined in the route parameters is added if present.

protected getNamespace([(string) $namespace = null ]) : string
Parameters
$namespace : (string) = null

valid namespace

Tags
since
1.0.0
Return values
string —

The request URL

parseRoutes()

Parse the router.

protected parseRoutes(string $route) : string
Parameters
$route : string

The route URL

Tags
since
1.0.0
Return values
string —

RemoveQueryString()

Remove the query string variables from the URL (if any). As the full.

protected RemoveQueryString(string $url, Request $request) : string
Parameters
$url : string

The full URL

$request : Request
Tags
since
1.0.0
Return values
string —

The URL with the query string variables removed

Search results