undertext / arouter
Annotation based router
v0.1.0
2018-09-27 14:30 UTC
Requires
- doctrine/annotations: 1.4.*
- psr/http-message: ^1.0
- psr/http-server-middleware: ^1.0
Requires (Dev)
- mockery/mockery: dev-master
- phpunit/phpunit: ^6.2
This package is auto-updated.
Last update: 2024-04-19 23:44:45 UTC
README
Php annotation based router. Documentation can be found here
Requirements
PHP version >= 7.1
Installation
To install ARouter, run the command below:
composer require undertext/arouter
Quick example
// 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.
Main documentation sections:
NOTE: Due to Doxygen parser all code examples with PHP annotations do not wrap those annotations in DocBlock comment