1. Go to this page and download the library: Download nabeelalihashmi/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/ */
namespace App\Controllers;
class HomeController
{
public function index()
{
echo 'Hi';
}
public function posts() {
echo 'My posts';
}
public function user($id) {
echo 'Here';
var_dump($id);
}
}
namespace App\Middlewares;
use IconicCodes\LightRouter\IMiddleware;
class LoginCheck implements IMiddleware{
public function handle() {
return true;
}
}
$router->addRoute('GET', '/user/{arg1}/{arg2}', [HomeController::class, 'user'], [MyMiddleware::class]);
class HomeController {
public function user($id, $name) {
var_dump($id);
var_dump($name);
}
}
$router->run();
$router->setNotFound(function() {
header('HTTP/1.1 404 Not Found');
echo '404 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.