In SYMFONY3, I use intensively in my code the dump(...) function of The VarDumper Component that works with the DebugBundle Configuration ("debug").
Once you move to the production settings all the dump(...)
that are in the code become an issue and throws errors because in [project]\app\AppKernel.php the setting looks like that:
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = [...];
if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
...
}
return $bundles;
}
.... other functions...
}
Symfony\Bundle\DebugBundle\DebugBundle()
is meant to work in 'dev' environment only. I could add it to the 'prod' environment but it is, for obvious performance reasons, not meant to be like that.
It means that one has to delete (or comment) all the dump(...)
in the code. I have quite a lot of it, so I wonder if there is a recommendation, regarding that specific topic, to move smoothly from "dev" to "prod" .
In the prod
environment you have to remove all dump()
calls at all. Thats why Symfony use dump
function only in dev
environment and not allow you to run code with that function in prod
environment.
Also it is not so good to have dump()
statements all around the code. You can test some parts of your code with this useful function but when you know that your code works well you can remove dump()
statement immediately. And you will not have any problems in the future.
You can use any of IDEs to replace all occurrences of dump()
to empty string and so you will have working code in prod
environment.