Debugging templates with dump()

Twig’s built-in DebugExtension provides the dump() function, which outputs a detailed representation of one or more variables directly in the rendered template.

Prerequisites

The dump() function is only available when Twig debug mode is active. Twig debug mode is enabled whenever iDebug is set to any non-zero value in source/config.inc.php. The typical choice for a development environment is -1:

$this->iDebug = -1;

Warning

Enable debug mode in development environments only. Any non-zero iDebug value exposes internal data and exception details in the browser output.

Usage

Dump a single variable:

{{ dump(oProduct) }}

Dump multiple variables at once:

{{ dump(oProduct, oViewConf) }}

Wrap the output in <pre> for better readability:

<pre>{{ dump(oProduct) }}</pre>

Calling dump() without arguments dumps all variables available in the current template scope. This is not recommended — OXID eShop templates contain many large objects, which makes the output difficult to read.