Skip to content
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

WIP [DebugBundle] Allow configuring a dumper while collecting dumps, add a default one writing to stderr when the cli-server is in use #14373

Closed
wants to merge 3 commits into from

Conversation

nicolas-grekas
Copy link
Member

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

When dump() is called, you all know this happens:
dump1

With this PR, dumps are duplicated in the console output of a php -S process:
dump2

This does not work with php app/console server:run but that is for an other PR.

@nicolas-grekas nicolas-grekas added the DX DX = Developer eXperience (anything that improves the experience of using Symfony) label Apr 16, 2015
if ('cli-server' === PHP_SAPI) {
$cloner = new VarCloner();
$dumper = new CliDumper('php://stderr', $this->charset);
$dumper->dump($cloner->cloneVar(sprintf('In %s on line %d', $file, $line)));
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't you just write to php://stderr instead of using the dumper ? Having all the info about the string does not make much sense IMO, and it could even get truncated by the dumper

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a shortcut to benefit from auto-selection of color support, but yes, it's possible.

Copy link
Member

Choose a reason for hiding this comment

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

but does it need to be colored as dumped strings ? It would be confusing in case the dumped value is also a string

Copy link
Member Author

Choose a reason for hiding this comment

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

I think so, but maybe in a different color/background. That's the kind of things we can tweak if the main idea is appealing to a majority.

Copy link
Member

Choose a reason for hiding this comment

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

the idea looks good to me

@javiereguiluz
Copy link
Member

👍 I like the idea. Mostly because I think it feels like the natural behavior that you'd expect when using the built-in web server and the dump() function.

My only concern is: will it become a mess if I output a lot of variables or few but complex variables?

@nicolas-grekas nicolas-grekas changed the title [VarDumper] Duplicate dumps on stderr when using the embeded PHP server [WIP] [VarDumper] Duplicate dumps on stderr when using the embeded PHP server Apr 18, 2015
@nicolas-grekas nicolas-grekas changed the title [WIP] [VarDumper] Duplicate dumps on stderr when using the embeded PHP server [DebugBundle] Allow configuring a dumper while collecting dumps, add a default one writting to stderr when the embeded PHP server is in use May 14, 2015
@nicolas-grekas nicolas-grekas changed the title [DebugBundle] Allow configuring a dumper while collecting dumps, add a default one writting to stderr when the embeded PHP server is in use [DebugBundle] Allow configuring a dumper while collecting dumps, add a default one writing to stderr when the embeded PHP server is in use May 14, 2015
@nicolas-grekas nicolas-grekas changed the title [DebugBundle] Allow configuring a dumper while collecting dumps, add a default one writing to stderr when the embeded PHP server is in use [DebugBundle] Allow configuring a dumper while collecting dumps, add a default one writing to stderr when the cli-server is in use May 14, 2015
@nicolas-grekas nicolas-grekas changed the title [DebugBundle] Allow configuring a dumper while collecting dumps, add a default one writing to stderr when the cli-server is in use WIP [DebugBundle] Allow configuring a dumper while collecting dumps, add a default one writing to stderr when the cli-server is in use May 14, 2015
@nicolas-grekas nicolas-grekas deleted the dump-stderr branch May 15, 2015 07:07
fabpot added a commit that referenced this pull request May 15, 2015
…olas-grekas)

This PR was merged into the 2.6 branch.

Discussion
----------

[DebugBundle] Allow alternative destination for dumps

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

This PR fixes #14608 by adding a new `debug.dump_destination` configuration option to give users control over a stream destination where dumps will be written to.
In HTTP mode, dumps are still/also collected in the toolbar.
This supersedes #14627, #14631 and #14373

Commits
-------

5f255e5 [DebugBundle] Allow alternative destination for dumps
5368483 [DebugBundle] Use output mechanism of dumpers instead of echoing
8cb2abb [DebugBundle] Always collect dumps
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)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants