In practice each new API version does not always have the same routes, so it makes sense to group them separately. Example:
// All routes for version 1
$app->group('/api/v1', function (RouteCollectorProxy $group) {
$group->group('/auth', function (RouteCollectorProxy $group) {
$group->get('/login', \App\Application\Actions\Version1\Auth\LoginAction::class);
$group->get('/logout', \App\Application\Actions\Version1\Auth\LogoutAction::class);
});
});
// All routes for version 2
$app->group('/api/v2', function (RouteCollectorProxy $group) {
$group->group('/auth', function (RouteCollectorProxy $group) {
$group->get('/login', \App\Application\Actions\Version2\Auth\LoginAction::class);
$group->get('/logout', \App\Application\Actions\Version2\Auth\LogoutAction::class);
});
});