$router->get('/users', 'UserController@index');
$router->post('/users/:id/edit', 'UserController@edit');
$router->put('/users/:id?', function ($id = null) { if ($id) { // logic for editing a user with a specific id } else { // logic for creating a new user } });This code defines a route for the endpoint "/users/:id?" using the PUT method, where ":id?" is an optional parameter. The route is mapped to a closure that handles both cases of editing an existing user or creating a new one, depending on whether the optional parameter is provided. Package library: PHP Router Map.