add(TwigMiddleware::create($app, $container->get(Twig::class))); // change first param to false for production $app->addErrorMiddleware(true, true, true); $app->get('/admin', function (Response $response, Twig $twig) { return $twig->render($response, 'admin.html.twig', [ 'name' => 'John', ]); }); return $app;