1. Go to this page and download the library: Download alexkratky/routex 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/ */
alexkratky / routex example snippets
use AlexKratky\URL;
use AlexKratky\Route;
use AlexKratky\RouteHandler;
Route::setError(Route::ERROR_NOT_FOUND, "404.php"); // only if you want custom error 404 page
Route::set('/', 'home.php'); // set routes - URI: '/', template file: 'home.php'
$URL = new URL(); // Creates a new instance of URL object
Route::setMiddlewaresPath($_SERVER['DOCUMENT_ROOT'] . '/middlewares/'); // only if you will use middlewares
Route::setControllersPath($_SERVER['DOCUMENT_ROOT'] . '/controllers/'); // optional (faster improvement)
$template_files = Route::search($URL->getString()); // Searches in all routes and find the right template file
$rh = new RouteHandler($_SERVER['DOCUMENT_ROOT'] . '/template/', $_SERVER['DOCUMENT_ROOT'] . '/controllers/', $_SERVER['DOCUMENT_ROOT'] . '/handlers/'); // *
$rh->setHandlers([
'latte' => 'LatteHandler'
]); // Sets custom handler for *.latte extension
$rh->handle($template_files); //