How to var_dump variables in twig templates?
As of Twig 1.5, the correct answer is to use the dump function. It is fully documented in the Twig documentation. Here is the documentation to enable this inside Symfony.
{{ dump(user) }}
You can use the debug
tag, which is documented here.
{% debug expression.varname %}
Edit: As of Twig 1.5, this has been deprecated and replaced with the new dump
function (note, it's now a function and no longer a tag). See also: The accepted answer above.