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) $nextReturn Values
\ResponseInterface
Description
public extractArgId (string $routeNamePart)
Function extractArgId Extract a argument id/name of route name part
Parameters
(string) $routeNamePartReturn Values
string|null
Description
public extractArgRegex (string $routeNamePart)
Function extractArgRegex Extract a argument regex of route name part
Parameters
(string) $routeNamePartReturn Values
string|null
Description
public findByCount (string $url, array $routes)
Function findByCount Find all routes by count spaces bar “/”
Parameters
(string) $url(array) $routesReturn Values
\Route[]
Description
public findByMethod (string $url, array $routes)
Function findByMethod Find all routes by method
Parameters
(string) $url(array) $routesReturn Values
array
Description
public findByName (string $url)
Function findByName Find a route by name/url
Parameters
(string) $urlReturn Values
array
Description
public findByRegex (string $url)
Function findByRegex Find a route by regular expression
Parameters
(string) $urlReturn 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) $methodReturn 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) $nextReturn Values
\ResponseInterface
Description
public hasRoute (string $name, string $method)
Function hasRoute Check if route match exists for name and method
Parameters
(string) $name(string) $methodReturn 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) $middlewaresReturn 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) $callbackReturn Values
void