PHP code example of elzekool / koolrouter
1. Go to this page and download the library: Download elzekool/koolrouter 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/ */
elzekool / koolrouter example snippets
use ElzeKool\KoolRouter\Router;
$router = new Router();
// Setup route
$router->map(
'GET /pages/[i:id]',
function($method, $path, $parameters, $extra) {
echo 'Hello i\'m page ' . $parameters['id'];
},
'page_view'
);
// Start routing
$router->run();
// Reverse routing
// (returns: /pages/10)
$route = $router->reverse('page_view', array(
'id' => 10
));