-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Description
Description
Currently there are the functions dd()
and dump()
that dumps the content of the given variable.
If used in the browser, the dump is perfectly readable and navigable.
The problems arise when using the functions in CLI.
In this case, in fact, we have a big listing that is hard to navigate.
More often, if the dump is really big, it goes out of the console (I use PHPStorm) and so part of the dumped tree is lost (also if it is possible to increase the number of lines shown in the CLI, but the other problems still remain).
I'm currently working on a Rector (https://github.com/rectorphp/rector) and I need to print very big dumps (the tree that represents the parsed PHP code).
Reading the tree in the CLI is impractical as there are many links between nodes and navigate them is really really hard.
So I created two small functions: ddf
and dumpf
.
They doo exactly what the corresponding dd
and dump
functions do: they dump the passed variable.
But, instead of dumping the variable in the medium used (CLI or browser) they always create a file and put into it an HTML version of the dump.
Doing this permits to have all the advantages of an HTML dump, but from the CLI.
It is also useful when working with API as, sometimes, the responses are parsed in a tree of related objects and navigate them in the CLI, again, is really hard.
WDYT? If you like the idea, I can submit a PR.