How to disable dump()
function,
when its in production environment?
If i forget the dump function anywhere It crashes with an 500 error
For Symfony 4.1+, you can modify index.php
this way:
if ($debug) {
umask(0000);
Debug::enable();
+ } else {
+ \Symfony\Component\VarDumper\VarDumper::setHandler(function($var) {});
+ }
Then dump()
will do nothing when called. If you want you can throw an Exception or write some log.
The problem is that the content of dump()
will go to the web debug toolbar in dev mode, which can be easily overlooked. When deploying such code to production, user will then see an inline dump()
!