<?php
namespace Fuz\AppBundle\Twig\Extension;
class DebugExtension extends \Twig_Extension
{
public function getFunctions()
{
return array (
new \Twig_SimpleFunction('dump', array('Symfony\Component\VarDumper\VarDumper', 'dump')),
);
}
public function getName()
{
return 'FuzAppBundle:Debug';
}
}
<h1>Variables passed to the view:</h1>
{% for key, value in _context %}
{% if key starts with '_' %}
{% else %}
<pre style="background: #eee">\{\{ key }}</pre>
\{\{ dump(value) }}
{% endif %}
{% endfor %}