Introduce DebugBarVarDumper for HTML variable dumping #344
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Symfony VarDumper component includes an
HtmlDumper
that dumps variables in a rich HTML format that allows for expanding and collapsing individual tree nodes in the dumped variable. This makes it much more practical to navigate large/deep variables that have been dumped.DebugBarVarDumper
provides a Debug Bar-friendly wrapper around the VarDumper component. It’s intended as an alternative toDataFormatter::formatVar
to enable this rich HTML interface. It provides for:Debug Bar-friendly styles for the VarDumper HTML.
Implements
AssetProvider
for returning VarDumper static assets (requires users ofJavascriptRenderer
to support inline assets).Simplifies/wraps
VarCloner
andHtmlDumper
function calls for cloning and dumping variables in a Debug Bar environment. VarDumper was originally written/targeted to be a replacement forvar_dump
, so the default behavior ofHtmlDumper
echoing static assets and variable dumps directly to the page output isn’t really appropriate. Furthermore, we must contend with several different Symfony versions going back to v2.6.0. This class provides a friendly wrapper over all of that.I have tested this with these Symfony versions:
All seem to work fine, with graceful degradation as needed.
Furthermore, the class is ready to take advantage of new features that I added and are upcoming in Symfony v3.4:
This feature will be valuable for the upcoming BacktraceCollector.
Screenshots of how this looks with some of the collectors. After this PR is merged, I'll submit more pull requests to enable these collectors to integrate with this new feature.
Request collector:

Rich variable dumping in the message collector:

Upcoming backtrace collector:
