I really like using the excellent Symfony VarDumper component. It provides such a nice way to display variables or objects that can get very large or complicated in OOP.
But there is something missing...
In my workflow, I add one or two dump
or dd
statement in my code before trying again. Then I see the result. Then I go back to my code... but here is the issue: sometimes, you don't know which part of the code triggered which dump statement. And going back to the right spot in your code might be difficult.
I've often found myself spending minutes looking for where is located that line of code (when I don't find myself committing the whole dump statement altogether in my repository, which happens more often than I would like to admit).
So here is a nice improvement over the regular dump
and dd
helpers provided by the Symfony VarDumper. These improved functions will show the name of the variable and where the debug statement is located. As an added bonus, the link is clickable and will open nicely in VsCode.
Note: one thing to mention is that these functions need to be loaded BEFORE your vendor/autoload.php file, since vendor code is loaded before your app code.
Happy coding everyone ;-)