}); $app->container->singleton('auth', function () { return new \App\Controller\AuthController(); }); // Create monolog logger and store logger in container as singleton // (Singleton resources retrieve the same log resource definition each time) $app->container->singleton('log', function () { $log = new \Monolog\Logger('slim-skeleton'); $log->pushHandler(new \Monolog\Handler\StreamHandler('../logs/app.log', \Monolog\Logger::DEBUG)); return $log; }); // Prepare view $app->view(new \Slim\Views\Twig()); $app->view->parserOptions = array('charset' => 'utf-8', 'cache' => realpath('../templates/cache'), 'auto_reload' => true, 'strict_variables' => false, 'autoescape' => true); $app->view->parserExtensions = array(new \Slim\Views\TwigExtension()); if (!DB::check()) { $app->get('/hello', function () use($app) { $app->render('hello.html'); })->name('hello'); $app->get(':anyroute+', function () use($app) { $app->redirectTo('hello'); }); $app->post('/up', function () use($app) { DB::tearDown(); DB::initialize(); DB::loadData(); $app->auth->doLogout(); $app->redirectTo('home'); })->name('setup'); } if (!$app->auth->user()) {