undertext/arouter

Annotation based router

Installs: 154

Dependents: 1

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 0

Open Issues: 0

pkg:composer/undertext/arouter

v0.1.0 2018-09-27 14:30 UTC

This package is auto-updated.

Last update: 2025-10-20 03:07:46 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

Build Status codecov