1. Go to this page and download the library: Download lizzyman04/file-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/ */
lizzyman04 / file-router example snippets
use FileRouter\FileRouter;
$router = new FileRouter(__DIR__ . '/routes');
$match = $router->match($_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI']);
if ($match === null) {
http_response_code(404);
} elseif ($match->isMethodNotAllowed()) {
http_response_code(405);
header('Allow: ' . implode(', ', $match->allowedMethods));
} else {
// $match->file — the route file to
$router = new FileRouter(__DIR__ . '/routes', [
// Where compiled routes are cached. Omit for no caching (compile per request).
'cacheDir' => __DIR__ . '/var/cache',
'cache' => true,
// How route files declare their HTTP methods. Default: Flow syntax.
'methodExtractor' => new \FileRouter\Extractor\FlowMethodExtractor(),
]);
$router->clearCache(); // invalidate the compiled table
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.