1. Go to this page and download the library: Download asko/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/ */
asko / router example snippets
use Asko\Router\Router;
$router = new Router();
$router->get("/hello/{who}", function(string $who) {
echo "Hello, {$who}";
});
$router->dispatch();
use Asko\Router\Router;
class AdminController
{
public function login()
{
echo "Login page goes here.";
}
}
$router = new Router();
$router->get("/admin/login", [AdminController::class, "login"]);
$router->dispatch();
use Asko\Router\Router;
function hello_world() {
echo "Hello, World!";
}
$router = new Router();
$router->get("/hello-world", "hello_world");
$router->dispatch();
use Asko\Router\Router;
$router = new Router();
$router->get("/hello-world", function() {
echo "Hello, World!";
});
$router->dispatch();