Reputation: 1496
I used the dump
function within one of our applications and our client got used to it during development (tbh I didn't know that it won't work in prod). Now the application is going live which means no more debug
mode - and no more dump
function.
Is there any way to enable the dump
function during prod?
Upvotes: 2
Views: 2137
Reputation: 101
Read Symfony documentation 🧐, function 'dump()' is part of 'VarDumper' component, it's a dev dependency, so if you want to use it in prod you need to install it as required dependency:
❌ $ composer require --dev symfony/var-dumper
✔ $ composer require symfony/var-dumper
Upvotes: 0
Reputation: 712
You have to indeed add this line to AppKernel.php:
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
But also change this boolean in app.php from false to true:
$kernel = new AppKernel('prod', true); // true is replacing false, in second argument here
Tested for Symfony 4.4 and works.
Upvotes: 0
Reputation: 904
Despite weird will of use dump()
in production env...
If I am not mistaken dump()
is from DebugBundle
which is enabled only in dev
and test
env.
public function registerBundles()
{
$bundles = [
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new AppBundle\AppBundle(),
];
if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
if ('dev' === $this->getEnvironment()) {
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
$bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle();
}
}
return $bundles;
}
As you can see above DebugBundle
is registered only in previous mentioned envs. Probably moving it out of the if
will allow you to use dump()
in production.
Upvotes: 1