Dump PHP variables like a pro

A Web Developer based in Belgium, specialized in PHP & JS development
Search for a command to run...

A Web Developer based in Belgium, specialized in PHP & JS development
No comments yet. Be the first to comment.
I recently needed to collect all changes in one file for reporting purposes. Found this article: https://ratfactor.com/cards/git-diff-with-new-files In case you need something similar on Windows, here

Some projects start with a grand plan. Others start because you just need to read a file without thinking too much about it. That was the case for spread-compat. I needed a common interface for CSV, X

With modern css, you can almost get rid of sass. But there is one last pain point : media queries. Not being able to use variables or an easy, common syntax for typical breakpoints is really annoying. That is, until you meet Media Queries Level 5. I’...

This is a quick article to share this demo I just made. https://codepen.io/lekoalabe/pen/JoPNWpX

Modals are typical UI elements for many web apps. There are countless packages dedicated to that specific features, each framework creating its own variation. Popular frameworks like Bootstrap also have custom code to deal with it. But all this feels...

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.
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 ;-)