Вариант 1
init_vars(){
$vars['x']='hello';
return $vars;
});
$app->get('/[upload]', function ($request, $response, $args) {
$vars= init_vars();
return $this->view->render($response, 'upload.html', $args);
})->setName('main');
$app->get('/show_file/{id}', function ($request, $response, $args){
$vars= init_vars();
$args['fileUri']= $fileUri;
return $this->view->render($response, 'show_file.html', $args);
})->setName('show_file');
Вариант 2
$vars['x']='hello';
$app->get('/[upload]', function ($request, $response, $args) use ($vars) {
$x = $vars['x'];
return $this->view->render($response, 'upload.html', $args);
})->setName('main');
$app->get('/show_file/{id}', function ($request, $response, $args) use ($vars){
$x = $vars['x'];
$args['fileUri']= $fileUri;
return $this->view->render($response, 'show_file.html', $args);
})->setName('show_file');