Twig Debug mode

How can I turn on Twig’s debug mode so I can use the dump function?


Following from the example in the guides you can do the following:

// Create app
$app = new \Slim\App();

// Get container
$container = $app->getContainer();

// Register component on container
$container['view'] = function ($container) {
    $view = new \Slim\Views\Twig('path/to/templates', [
        'debug' => true, // This line should enable debug mode
        'cache' => 'path/to/cache'
    $view->addExtension(new \Slim\Views\TwigExtension(
    // This line should allow the use of {{ dump() }}
    $view->addExtension(new \Twig_Extension_Debug());

    return $view;
1 Like