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