# Twig Debug mode

**URL:** <https://discourse.slimframework.com/t/twig-debug-mode/535>\
**Category:** Questions\
**Created:** [July 20, 2016, 11:08pm UTC](https://discourse.slimframework.com/t/twig-debug-mode/535 "2016-07-20T23:08:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ML88](https://avatars.discourse-cdn.com/v4/letter/m/f14d63/32.png) [@ML88](https://discourse.slimframework.com/u/ML88)\
**Post date:** [July 20, 2016, 11:08pm UTC](https://discourse.slimframework.com/t/twig-debug-mode/535/1 "2016-07-20T23:08:37Z")

</div>

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

Thanks!

---

<div class="post-metadata">

**Author:** ![silentworks](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/silentworks/32/10_2.png) [@silentworks](https://discourse.slimframework.com/u/silentworks)\
**Post date:** [July 21, 2016, 7:26am UTC](https://discourse.slimframework.com/t/twig-debug-mode/535/2 "2016-07-21T07:26:46Z")

</div>

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

```php
<?php
// 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(
        $container['router'],
        $container['request']->getUri()
    ));
    
    // This line should allow the use of {{ dump() }}
    $view->addExtension(new \Twig_Extension_Debug());

    return $view;
};

```
