$app = new \Slim\Slim(array('view' => '\\Slim\\LayoutView', 'layout' => 'layouts/main.php')); // hook before.router, now $app is accessible in my views $app->hook('slim.before.router', function () use($app) { $app->view()->setData('app', $app); }); // views initiatilisation $view = $app->view(); $view->setTemplatesDirectory('views'); // GET / $app->get('/', function () use($app) { $app->render('index.php'); })->name('index'); // POST de connexion $app->post('/logUser', function () use($app) { session_destroy(); $isconnected = User::connect_user($_POST['mail'], $_POST['password']); if ($isconnected) { $tache = Task::getTaskByClassId($_SESSION["classid"]); $app->redirect($app->urlFor('calendrier')); } else { $app->flash('erreur', 'Vous ne remplissez pas les conditions requises'); $app->redirect($app->urlFor('index')); } })->name('logUser'); $app->post('/logTeacher', function () use($app) { session_destroy(); $isconnected = User::connect_teacher($_POST['mail'], $_POST['password']); var_dump($isconnected); if ($isconnected) { $app->redirect($app->urlFor('indexTeacher')); } else {