Skip to content

[VarDumper] Add ddf() and dumpf() functions to dump to a file #35801

@Aerendir

Description

@Aerendir

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.

Schermata_2020-02-20_alle_15_03_48

Doing this permits to have all the advantages of an HTML dump, but from the CLI.

Schermata 2020-02-20 alle 15 07 20

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions