use getRouter\Router; $router = new Router(); // Define a route $router->get('/home', function() { echo "Welcome to the Home page!"; });
use getRouter\Router; $router = new Router(); // Define a route with a parameter $router->get('/hello/{name}', function($name) { echo "Hello, $name!"; });
use getRouter\Router; $router = new Router(); // Group routes together $router->group('/admin', function($router) { $router->get('/dashboard', function() { echo "Welcome to the Admin Dashboard!"; }); $router->get('/settings', function() { echo "Welcome to the Admin Settings page!"; }); });In this example, we group multiple routes together under the /admin endpoint. This keeps related routes organized and makes it easier to manage them. The routes defined inside the group function are called with the /admin prefix, so the full URLs would be /admin/dashboard and /admin/settings. Package Library: The getRouter package is a custom library developed for PHP and is not an officially released package.