show code

  • php code
// Register Twig View helper
$container['view'] = function ($c) {
    $view = new \Slim\Views\Twig(PROJECT_PATH . '/templates', [
        'cache' => false,
        // 'cache' => PROJECT_PATH . '/temp/twig'
    ]);

    // Instantiate and add Slim specific extension
    $view->addExtension(new Slim\Views\TwigExtension(
        $c['router'],
        $c['request']->getUri()
    ));

    return $view;
};