8000 VarDumper and DebugBundle by nicolas-grekas · Pull Request #10640 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

VarDumper and DebugBundle #10640

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
Sep 23, 2014
Merged

VarDumper and DebugBundle #10640

merged 31 commits into from
Sep 23, 2014

Conversation

nicolas-grekas
Copy link
Member
Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets none
License MIT
Doc PR symfony/symfony-docs#4243

From a user land point of view, this PR creates a global dump() function that is to be used instead of var_dump(). The component can be used standalone in any dev workflow. Please see the provided README for details.

When used with the Framework bundle, variables passed to dump() are dumped in a new dedicated panel in the web toolbar. The function is also available in twig templates.

Regarding the implementation, I'm pretty sure you'll find a lot to comment. As I'm sure of nothing else, not even the names of things, please do.

I tried to organize this PR in several commits, from the most fundamental algorithm to pure Symfony glue.
I suggest you follow this order while progressing in the review and the discussion around this PR, so that we can together validate commits one after the other.

Don't hesitate to fork the PR and submit PR on it, I'll cherry-pick your patches.

TODO:

  • open a doc PR: [WIP] var-dumper component symfony-docs#4243
  • open a PR on the Standard edition: Enable DebugBundle symfony-standard#710
  • prefix the CSS classes
  • tests for the DebugBundle + other Symfony glue classes
  • inline css and js for compat with e.g. Silex
  • finish and merge nicolas-grekas/Patchwork-Dumper#5 for better UX
  • show a dump excerpt on hovering the icon in the toolbar
  • verify README and comments
  • validate interfaces/names (Caster / Cloner / Dumper)
  • validate new VarDumper component + DebugBundle
  • validate Resource/ext/ vs independent repos.
  • test and define behavior after KernelEvents::RESPONSE
  • update dependencies between components/bundles and composer.json files
  • no hard dep on iconv

Not for this PR but might be worth later:

  • show a light stack trace + timing + memory at debug() calls
  • create a "theme" concept for custom colors/UX

@Koc
Copy link
Contributor
Koc commented Apr 5, 2014

Awesome bulk of work was done! Very interesting component. I hope it will be part of Symfony.

{
foreach ($c as $k => $obj) {
$a[$k] = $obj;
if (null !== $i = $c->getInfo()) $a["\0~\0$k"] = $i;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code style : it should be on two lines, using brackets

@nicolas-grekas
Copy link
Member Author

Here is the new default rendering:
capture du 2014-09-23 14 59 13
capture du 2014-09-23 14 58 57

I removed the option for several rendering engines and choose to keep the "base" one. This removes the Patchwork and @OwlyCode renderer. As the JsonDumper is not used anymore, I also removed it and its related tests+doc from the git history of this PR. I kept them in patchwork/dumper so they can come back again later.

I also enhanced the base rendering engine with some JS. This should match some of your suggestions @webmozart .
The main benefit of this approach is that enhancing the HtmlDumper not only enhances the profiler panel, but also inline dumps (the twig function and dump()+exit in your code).

(the remaining fabbot error is intentional)

@fabpot
Copy link
Member
fabpot commented Sep 23, 2014

It took time, but here we go, this is in now. Thank you very much @nicolas-grekas.

@fabpot fabpot merged commit 80fd736 into symfony:master Sep 23, 2014
fabpot added a commit that referenced this pull request Sep 23, 2014
…an, moux2003, tony-co, romainneutron, oscherler, lyrixx)

This PR was merged into the 2.6-dev branch.

Discussion
----------

VarDumper and DebugBundle

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | none
| License       | MIT
| Doc PR        | none

From a user land point of view, this PR creates a global `dump()` function that is to be used instead of `var_dump()`. The component can be used standalone in any dev workflow. Please see the [provided README](https://github.com/symfony/symfony/pull/10640/files?short_path=52d526f#diff-52d526f19bc9e3825c80e7694755409c) for details.

When used with the Framework bundle, variables passed to `dump()` are dumped in a new dedicated panel in the web toolbar. The function is also available in twig templates.

Regarding the implementation, I'm pretty sure you'll find a lot to comment. As I'm sure of nothing else, not even the names of things, please do.

I tried to organize this PR in several commits, from the most fundamental algorithm to pure Symfony glue.
I suggest you follow this order while progressing in the review and the discussion around this PR, so that we can together validate commits one after the other.

Don't hesitate to fork the PR and submit PR on it, I'll cherry-pick your patches.

TODO:
- [x] open a doc PR: symfony/symfony-docs#4243
- [x] open a PR on the Standard edition: symfony/symfony-standard#710
- [x] prefix the CSS classes
- [x] tests for the DebugBundle + other Symfony glue classes
- [x] inline css and js for compat with e.g. Silex
- [x] finish and merge nicolas-grekas/Patchwork-Dumper#5 for better UX
- [x] show a dump excerpt on hovering the icon in the toolbar
- [x] verify README and comments
- [x] validate interfaces/names (Caster / Cloner / Dumper)
- [x] validate new VarDumper component + DebugBundle
- [x] validate Resource/ext/ vs independent repos.
- [x] test and define behavior after KernelEvents::RESPONSE
- [x] update dependencies between components/bundles and composer.json files
- [x] no hard dep on iconv

Not for this PR but might be worth later:
- show a light stack trace + timing + memory at debug() calls
- create a "theme" concept for custom colors/UX

Commits
-------

80fd736 [DebugBundle] Enhance some comments
2e167ba [TwigBridge] add Twig dump() function + tests and fixes
0f8d30f [VarDumper] Replace \e with \x1B in CliDumper to support colour in PHP < 5.4
d43ae82 [VarDumper] Add workaround to https://bugs.php.net/65967
a8d81e4 [DebugBundle] Inlined assets to avoid installation issues
5f59811 [DebugBundle] Add doc example for Twig usage
e4e00ef [TwigBridge] DumpNode and Token parser
de05cd9 [DebugBundle] enhance dump excerpts
49f13c6 [HttpKernel] add tests for DumpDataCollector
081363c [HttpKernel] tests for DumpListener
0d8a942 [VarDumper] add Stub objects for cutting cleanly and dumping consts
c8746a4 [DebugBundle] add tests for twig and for the bundle
8d5d970 [DebugBundle] adjust after review
eb98c81 [DebugBundle] dump() + better Symfony glue
9dea601 [DebugBundle] global dump() function for daily use
297d373 [VarDumper] README, LICENSE and composer.json
a69e962 [VarDumper] tests for HtmlDumper
5eaa187 [VarDumper] tests for CliDumper
e6dde33 [VarDumper] HTML variant of the CLI dumper
fa81544 [VarDumper] CLI dedicated dumper and related abstract
1d5e3f4 [VarDumper] interface for dumping collected variables
0266072 [VarDumper] casters for DOM objects
c426d8b [VarDumper] casters for Doctrine objects
0a92c08 [VarDumper] casters for PDO related objects
da3e50a [VarDumper] casters for SPL data structures
c91bc83 [VarDumper] casters for exceptions representation
3ddbf4b [VarDumper] add casters for per class/resource custom state extraction
5b7ae28 [VarDumper] symfony_debug ext. fast and memory efficient cloning algo
07135a0 [VarDumper] algo to clone any PHP variable to a breadth-first queue
4bf9300 [Debug] a README for the debug extension
eec5c92 [Debug] Symfony debug extension
@nicolas-grekas nicolas-grekas deleted the var-debug branch September 23, 2014 16:55
@mykiwi
Copy link
Contributor
mykiwi commented Sep 23, 2014

👏

@mickaelandrieu
Copy link
Contributor

This is an amazing enhancement, thanks to all contributors !

@kristoffeys
Copy link

awesome! 👊

@bonswouar
Copy link

Was waiting impatiently for this feature, thanks guys !

EDIT : Though, bad news for LadybugBundle, won't be very useful anymore...

fabpot added a commit to symfony/symfony-standard that referenced this pull request Sep 25, 2014
This PR was merged into the 2.6-dev branch.

Discussion
----------

Enable DebugBundle

This enables the DebugBundle as proposed in symfony/symfony#10640

Commits
-------

dadea61 Enable DebugBundle
@nicolas-grekas
Copy link
Member Author

For reference, if you'd like to use VarDumper / dump() in your Symfony 2.3/4/5 app, I backported the Debug-Bundle, here it is:
https://github.com/tchwork/debug-bundle

@xabbuh
Copy link
Member
xabbuh commented Dec 2, 2014

@nicolas-grekas Could it be worth to add this information to the documentation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DX DX = Developer eXperience (anything that improves the experience of using Symfony) Feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0