getContainer(); /** * @var Configuration $config */ $config = $container->get('config'); // Twig $templateCache = false; $twig = Twig::create(APP_TEMPLATES_DIR, [ 'cache' => $templateCache ]); // Add the global variables $twig->getEnvironment()->addGlobal('site_name', $config->get('site.name')); $twig->getEnvironment()->addGlobal('site_description', $config->get('site.description')); $flash = $container->get(SessionInterface::class)->getFlash(); $twig->getEnvironment()->addGlobal('flash', $flash); $app->add(TwigMiddleware::create($app, $twig)); // Add the error handling middleware $app->addErrorMiddleware(true, true, true); } }