As the name says, it is made to be basic and direct.
Router Class
Name | Description |
---|---|
__construct | Function __constructs |
__invoke | Function __invoke |
Handles a request and produces a response. | |
extractArgId | Function extractArgId |
Extract a argument id/name of route name part | |
extractArgRegex | Function extractArgRegex |
Extract a argument regex of route name part | |
findByCount | Function findByCount |
Find all routes by count spaces bar “/” | |
findByMethod | Function findByMethod |
Find all routes by method | |
findByName | Function findByName |
Find a route by name/url | |
findByRegex | Function findByRegex |
Find a route by regular expression | |
getResponse | Function getResponse |
Get a ResponseInterface Object or router run | |
getRoute | Function getRoute |
Get route requested | |
getRoutes | Function getRoutes |
Get a array with all routes into instance of router | |
handle | Function __invoke |
Handles a request and produces a response. | |
hasRoute | Function hasRoute |
Check if route match exists for name and method | |
setRequest | Function getResponse |
Set a ServerRequestInterface Object for router run | |
setRoute | Function setRoute |
Set a route for router | |
setRouteByAnnotation | Function setRouteByAnnotation |
Receives a class as an argument, and works with the comment blocks as @Route |
Description
public __construct (void)
Function __constructs
Parameters
This function has no parameters.
Return Values
void
Description
public __invoke (\ServerRequestInterface $request, \ResponseInterface $response, callable $next)
Function __invoke Handles a request and produces a response.
May call other collaborating code to generate the response.
Parameters
(\ServerRequestInterface) $request
(\ResponseInterface) $response
(callable) $next
Return Values
\ResponseInterface
Description
public extractArgId (string $routeNamePart)
Function extractArgId Extract a argument id/name of route name part
Parameters
(string) $routeNamePart
Return Values
string|null
Description
public extractArgRegex (string $routeNamePart)
Function extractArgRegex Extract a argument regex of route name part
Parameters
(string) $routeNamePart
Return Values
string|null
Description
public findByCount (string $url, array $routes)
Function findByCount Find all routes by count spaces bar “/”
Parameters
(string) $url
(array) $routes
Return Values
\Route[]
Description
public findByMethod (string $url, array $routes)
Function findByMethod Find all routes by method
Parameters
(string) $url
(array) $routes
Return Values
array
Description
public findByName (string $url)
Function findByName Find a route by name/url
Parameters
(string) $url
Return Values
array
Description
public findByRegex (string $url)
Function findByRegex Find a route by regular expression
Parameters
(string) $url
Return Values
array|null
Description
public getResponse (void)
Function getResponse Get a ResponseInterface Object or router run
Parameters
This function has no parameters.
Return Values
\ResponseInterface
Description
public getRoute (string $url, string $method)
Function getRoute Get route requested
Parameters
(string) $url
(string) $method
Return Values
\Route|null
Description
public getRoutes (void)
Function getRoutes Get a array with all routes into instance of router
Parameters
This function has no parameters.
Return Values
array|\Route[]
Description
public handle (\ServerRequestInterface $request, \ResponseInterface $response, callable $next)
Function __invoke Handles a request and produces a response.
May call other collaborating code to generate the response.
Parameters
(\ServerRequestInterface) $request
(\ResponseInterface) $response
(callable) $next
Return Values
\ResponseInterface
Description
public hasRoute (string $name, string $method)
Function hasRoute Check if route match exists for name and method
Parameters
(string) $name
(string) $method
Return Values
bool
Description
public setRequest (void)
Function getResponse Set a ServerRequestInterface Object for router run
Parameters
This function has no parameters.
Return Values
\ServerRequestInterface
Description
public setRoute (string|array $url, string|array $method, string|\Clousure $callback, string|array $middlewares)
Function setRoute Set a route for router
Parameters
(string|array) $url
(string|array) $method
(string|\Clousure) $callback
(string|array) $middlewares
Return Values
\Router
Description
public setRouteByAnnotation (string $annotation, string $callback)
Function setRouteByAnnotation Receives a class as an argument, and works with the comment blocks as @Route
Parameters
(string) $annotation
(string) $callback
Return Values
void