Php annotation based router. Documentation can be found here
PHP version >= 7.1
To install ARouter, run the command below:
composer require undertext/arouter
// Enable annotations autolading. This is a required step.
AnnotationRegistry::registerLoader('class_exists');
// Build annotaion based router, find controllers in 'src/Controller' folder.
$router = RouterFactory::getRouter('src/Controller');
// Get response based on request.
try {
$response = $router->getResponse(ServerRequest::fromGlobals());
} catch (RouteHandlerNotFoundException $e) {
$response = new Response(404, [], "Route not found"); // This is an example of Guzzle HTTP Response usage.
}
outputResponse($response); // outputResponse is a function that converts response to string and outputs it.
NOTE: Due to Doxygen parser all code examples with PHP annotations do not wrap those annotations in DocBlock comment