1. Go to this page and download the library: Download mattvb91/lightrouter 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/ */
mattvb91 / lightrouter example snippets
$router = new mattvb91\LightRouter\Router();
$router->addRoute('/', MyController::class);
$router->run();
//Your route definition
$router->addRoute('/user/view/:user', UserController::class, 'view');
//In your UserController::class
public function view(User $user)
{
//$user is already fully loaded for you.
}
public class CustomModel implements LightRouteModelInterface
{
public static function getForLightRoute($routeParam): LightRouteModelInterface
{
//Use $routeParam to load your model class and return the instance
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.