[ 'displayErrorDetails' => true ] ]); } else { $app = new \Slim\App([ 'settings' => [ 'displayErrorDetails' => false ] ]); } $container = $app->getContainer(); // Carico gestione errori Webcharm require_once 'webcharm-error.php'; // Registro Flash provider $container['flash'] = function () { return new \Slim\Flash\Messages(); }; // Registro Twig provider $container['twig'] = function () { // Definisco la cartella templates designata a contenere i template $twig_loader = new Twig_Loader_Filesystem('templates'); $twig = new Twig_Environment($twig_loader); $twig->addExtension(new Twig_Extensions_Extension_I18n()); //Definisco funzioni supplementari a TWIG $function_twig_urlfor = new Twig_SimpleFunction('url_for', function ($name, $data = [], $queryParams = []) { global $container; return $container->router->pathFor($name, $data, $queryParams); }); $function_twig_giorno_testo = new Twig_SimpleFunction('day_text', function ($data) { $giorni = array('domenica', 'lunedì', 'martedì', 'mercoledì', 'giovedì', 'venerdì', 'sabato'); $date = DateTime::createFromFormat('d/m/Y', $data); return $giorni[$date->format('w')]; }); $twig->addFunction($function_twig_urlfor); $twig->addFunction($function_twig_giorno_testo); return $twig; }; include_once 'urls.php'; $response = $app->run(true); //Silent mode, wont send the response $response = $response->withoutHeader("Content-Length"); //Remove the Content-Length $app->respond($response); //Now we send the response