Skip to content

Repository files navigation

ARouter

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

Build Status codecov

About

Annotation based router

Resources

Stars

1 star

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages