use RouterRun\Router; $router = new Router(); $router->get('/', function() { echo 'Hello World!'; }); $router->run();
$router->get('/users/{id}', function($params) { $id = $params['id']; echo "User ID: $id"; });
$router->group('/admin', function() use ($router) { $router->get('/dashboard', function() { echo 'Admin Dashboard'; }); $router->get('/users', function() { echo 'Admin Users'; }); });This example shows how routing can be grouped together for easier management and organization. Here, a `/admin` prefix is added to two URLs, and both routes are added to a closure that is passed to the `group()` method. The `$router` instance is passed to the `use` keyword to make it available within the closure. Once the routes are defined, the `run()` method can be called as usual to handle incoming requests. Package Library: The PHP Router Run library is an open-source package available on Packagist under the `router-run/router-run` package name. This library doesn't have any dependencies and is easy to use, making it a great choice for developers looking for a lightweight routing solution.