PHP code example of undertext / arouter
1. Go to this page and download the library: Download undertext/arouter library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
undertext / arouter example snippets
// Enable annotations autolading. This is a xists');
// 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.