Hi - trying to nest routes in Slim4. But i am getting errors and i cant find anything specific in the documentation around syntax for this. In my route config this works:
$app->group('/user', function (RouteCollectorProxy $group) {
$group->get('/accommodation/{accommodationid:\d+}/quote', QuoteHandler::class);
$group->get('/accommodation/{accommodationid:\d+}/basenightlyrates/{id:\d+}', GetBaseNightlyRatesHandler::class);
$group->delete('/accommodation/{accommodationid:\d+}/basenightlyrates/{id:\d+}', DeleteBaseNightlyRateHandler::class);
$group->post('/accommodation/{accommodationid:\d+}/basenightlyrates', AddBaseNightlyRateHandler::class);
$group->put('/accommodation/{accommodationid:\d+}/basenightlyrates/{id:\d+}', UpdateBaseNightlyRateHandler::class);
})->add(new JsonHeader())->add(UserAuthentication::class);
This doesnt work:
$app->group('/user', function (RouteCollectorProxy $group) {
$app->group('/accommodation/{accommodationid:\d+}', function (RouteCollectorProxy $group) {
$group->get('/quote', QuoteHandler::class);
$group->get('/basenightlyrates/{id:\d+}', GetBaseNightlyRatesHandler::class);
$group->delete('/basenightlyrates/{id:\d+}', DeleteBaseNightlyRateHandler::class);
$group->post('/basenightlyrates', AddBaseNightlyRateHandler::class);
$group->put('/basenightlyrates/{id:\d+}', UpdateBaseNightlyRateHandler::class);
});
})->add(new JsonHeader())->add(UserAuthentication::class);
I get following error on the nested $app->group statement…“Undefined variable: app”