Description
On http://symfony.com/doc/current/templating/debug.html it is said that the twig dump()
function is only available if the kernel.debug
setting is true
and that it would result in an application error to call it if kernel.debug
is false
.
By design, the dump() function is only available if the kernel.debug setting (in config.yml) is true, to avoid leaking sensitive information in production. In fact, trying to use the dump() function when kernel.debug is false (for example in the prod environment) will result in an application error.
But as far as I see this statement is wrong (or at least very unprecise).
The Symfony\Bridge\Twig\Extension\DumpExtension
is registered as soon as the DebugBundle
is loaded. No matter what kernel.debug
says.
In the default AppKernel
coming with the Symfony Standard edition, the DebugBundle
is loaded depending on the environment and not kernel.debug
. See:
// app/AppKernel.php
public function registerBundles()
{
// ...
if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
I am suggesting to change the wording of this documentation's paragraph to something like this:
By design, the dump() function is only available in the
dev
andtest
environments, to avoid leaking sensitive information in production. In fact, trying to use the dump() function in the prod environment will result in an application exception.