1. Go to this page and download the library: Download ooobii/quick-router 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/ */
use \ooobii\QuickRouter\Router\Router;
$router = new Router('/api/v1', TRUE);
if(!$router->process()) {
//url provided doesn't have a route specified.
}
use \ooobii\QuickRouter\Router\Router;
$router_v1 = new Router('/api/v1', TRUE);
$router_v2 = new Router('/api/v1', TRUE);
if(!$router_v1->process() && !$router_v2->process()) {
//url provided doesn't have a route specified.
}
//define an error route for exceptions encountered during route handling.
$router->addErrorRoute(500, function($exception) {
return [ 'error' => $exception->getMessage() ];
});
//define an error route for requests that do not have endpoints defined.
$router->addErrorRoute(404, function() {
return [ 'error' => 'Endpoint not found.' ];
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.