1. Go to this page and download the library: Download celema/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/ */
celema / router example snippets
use Celema\Router\Dispatcher;
use Celema\Router\Router;
use Celema\Router\RoutingHandler;
$router = new Router();
$router->get('/{name}', function (string $name) use ($responseFactory) {
$response = $responseFactory->createResponse();
$response->getBody()->write("<h1>{$name}</h1>");
return $response;
});
$handler = new RoutingHandler($router, new Dispatcher());
$response = $handler->handle($request);