1. Go to this page and download the library: Download liamrabe/basic-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/ */
liamrabe / basic-router example snippets
use LiamRabe\BasicRouter\Middleware\AbstractMiddleware;
use LiamRabe\BasicRouter\Controller\AbstractErrorController;
use LiamRabe\BasicRouter\DataCollection\Response;
use LiamRabe\BasicRouter\DataCollection\Request;
use LiamRabe\BasicRouter as Router;
class APIMiddleware {
public static function handle() {
return true;
}
}
class AppMiddleware {
public static function handle() {
return true;
}
}
function handleRoute(Request $request, Response $response): Response {
$response->setHeader('Content-Type', 'text/html');
$response->setBody('Hello, world!');
$response->setStatus(200);
return $response;
}
try {
/** setErrorController & setMiddleware are
/** Use this if you want to register a route on all HTTP methods */
Router::all('/', [AbstractController::class, 'handleRoute']);