1. Go to this page and download the library: Download genai/routing 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/ */
genai / routing example snippets
use GenAI\Routing\Router;
$router = new Router();
$router->get('/users', 'UserController@index');
$router->get('/user/{id}', 'UserController@show');
$router->post('/users', 'UserController@create');
// You supply the method + path (e.g. from your front controller).
$match = $router->match('GET', '/user/5');
if ($match === false) {
// No route matched — send your 404 response.
header('HTTP/1.1 404 Not Found');
exit;
}
$match->getHandler(); // 'UserController@show'
$match->getParams(); // array('id' => '5')
$match->getController(); // 'UserController'
$match->getAction(); // 'show'
$match->getParam('id'); // '5'