Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[VarDumper] Introduce a new way to collect dumps through a server dumper#23831
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
stof commentedAug 8, 2017
disabling dumps from the data collector by default may not be a good idea. |
ogizanagi commentedAug 8, 2017
f24712e might be a solution to this. |
ogizanagi commentedAug 11, 2017
Last updates from yesterday (I've update the PR description & screens) with features I expected to add in a another PR, but here we are:
|
| ->end() | ||
| ->arrayNode('server_dump')->canBeEnabled() | ||
| ->children() | ||
| ->scalarNode('host')->defaultValue('tcp://0.0.0.0:9912')->end() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I would not make this configurable in the config but as an env var. Like for the web server, imagine a scenario where you are working on many projects in parallel. It's easier to tweak an env var from the outside. Also, if the server is not a Symfony app, having the server address as an env var helps as well :)
ogizanagiAug 12, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Indeed, great idea. Done inb002175
| { | ||
| $this | ||
| ->setName('server:dump') | ||
| ->addOption('host',null, InputOption::VALUE_REQUIRED,'The server host',$this->defaultHost) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
If you agree with the config removal, this should also read from the env var.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Option removed in favor of using the env var.
| * use | ||
| * @param callable[] $contextProviders Callables indexed by name returning a context array | ||
| */ | ||
| publicfunction__construct($host,DataDumperInterface$wrappedDumper =null,$swallows =true,array$contextProviders =array()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
$host would then accept an empty string, which would make it read the env var.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I usednull instead of an empty string for now. Any reason to favor the empty string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
null is perfect ofc
| */ | ||
| class DumpServer | ||
| { | ||
| constHOST_ENV_VAR ='VAR_DUMPER_SERVER'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
why not inject with%env()% and keep this at the config level..
ogizanagiAug 12, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Yes, we could leverage Symfony's env support for this, hence no need for the previous commit. But the rational here to me is that you probably don't need to make the env var itself configurable and when working with multiple projects (even ones not using the DebugBundle), you don't have to ensure the same env var is used. Just set it and it works out of the box.
Still, that'll be the most flexible and would avoid hardcoding this behavior, while we could just configure in the standard-edition and flex recipe:
parameters:env(VAR_DUMPER_SERVER):'tcp://0.0.0.0:9912'debug:server_dump:host:'%env(VAR_DUMPER_SERVER)%'
(or directly in DebugBundle'sservices.xml, as stated below indeed. No need for thedebug.server_dump.host option. But that'll still only work out of the box if you use the DebugBundle)
@fabpot : What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
note we dont need debug.server_dump.host per se, it can be done directly in services.xml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I don't see the need to change the env var name.
ogizanagi commentedAug 21, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I've brought some new changes and added some tests. The PR is ready on my side. deps=high failure is expected. Fixed on HHVM build, probably not the best way.
Fixed on AppVeyor by setting |
nicolas-grekas left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
that's interesting, I need to checkout and play with it for better feedback :)
| "ext-iconv":"*", | ||
| "twig/twig":"~1.34|~2.4" | ||
| "twig/twig":"~1.34|~2.4", | ||
| "symfony/process":"~3.4|~4.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
alpha order :)
| * | ||
| * @author Maxime Steinhausser <maxime.steinhausser@gmail.com> | ||
| * | ||
| * @final since version 3.4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
just@final (since version 3.4 suggests is existed before, which is not the case)
| if ($this->logger) { | ||
| $this->logger->warning('Unable to decode a message from {clientId} client.',array( | ||
| 'clientId' =>$clientId, | ||
| )); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Should be on one line (I haven't checked if you have other occurrences of similar lines).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Fixed
| $payload =unserialize(base64_decode($message)); | ||
| // Impossible to decode the message, give up. | ||
| if (false ===$payload) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
That does not work if you send a message that is not base64 encoded. PHP will vail out on line 65.
ogizanagiAug 24, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
base64_decode won't fail on a non base64 encoded string AFAIK, butunserialize will trigger a notice. I think silencing it is enough but let me know.
| { | ||
| $this | ||
| ->setName('server:dump') | ||
| ->addOption('output',null, InputOption::VALUE_REQUIRED,'An file path to save dumped data in html format, or null to display on CLI output.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
A file ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
What about allowing to dump on STDOUT? Which means that everything else should be sent to STDERR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
HTML, not html
ogizanagiAug 24, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
What about allowing to dump on STDOUT? Which means that everything else should be sent to STDERR.
Using STDERR for command titles & comments is a fair point, I did it.
For dumps, the CliDumper will already use STDOUT. I also kept the context informations on STDOUT.
Or did you actually mean removing the--output option in favor of automatically using the HtmlDumper in the case of the output being redirected to a file or piped?
AFAIK, the only simple way to tell that is by usingposix_isatty, which won't be available on Windows (or perhapsfstat mode, but not sure about this being reliable on Windows neither).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
What about replacing the--output option by a--format option and extract processing in proper descriptors? It would let the user redirect or pipe the output and may allow other streamable formats like json-text-sequence to be implemented next.
Extracting descriptors from the command might also answer#23831 (comment) by allowing reuse and easing tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Done.
| $this->filesystem->appendToFile($outputFile,sprintf('<style>%s</style><script>%s</script>',self::$style,self::$javascript)); | ||
| } | ||
| $io->comment(sprintf('Consult collected dumps in html format by opening "%s" in your browser.',realpath($outputFile))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I let you change html to HTML everywhere :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Fixed 😄
| */ | ||
| class ServerDumpCommandextends Command | ||
| { | ||
| privatestatic$style = <<<'CSS' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I would store the styles in a file underResources/ so that it's more easily reusable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Still something useful considering#23831 (comment) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Done.
| } | ||
| CSS; | ||
| privatestatic$javascript = <<<'JS' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Same for this piece of JS.
| }); | ||
| } | ||
| privatefunctiondisplayDumpCli(SymfonyStyle$io,Data$data,array$context,$clientId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
If I'm creating my own server (like explained in the PR description), I would probably like to be able to reuse the logic in those 2 private methods, right?
ogizanagiAug 24, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I consider this command as a final application, not meant to be extended. That's why I also made it@final.
If someone wants to create his own server app, he'll probably want to integrate dumps his own way in his application and won't reuse theServerDumpCommand output. He'll create his own script collecting & processing dumps (perhaps by dumping it into a json file to be consumed by a ReactJS application for instance) using theDumpServer class.
ogizanagi commentedSep 24, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Last update: remove the Feature freeze is coming very soon. |
fabpot commentedOct 10, 2017
I'd like to test it more thoroughly. Let's move it to 4.1. |
ogizanagi commentedMar 11, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I may be a bit late to the party considering the upcoming 4.1 feature freeze. But in any case, this is now rebased, using PHP 7.1 features and tested on a 4.1 app. Everything still working fine :) Tests failures are unrelated (see#26489). |
antonmedv commentedMar 12, 2018
Will be cool to have it. Like output on rails or elixir/phoenix apps. |
ogizanagi commentedMar 22, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
When I started this PR, I also have in mind to provide a full featured web & cli app to centralize dumps & logs, but didn't take enough time yet to experiment it. Anyway this PR is already a big step to me, and I already have some other small improvements to come first in order to help using it easily on any context.
Currently, code excerpts are only retrieved by the SourceContextProvider for twig template. Being able to always getting the excerpt would require duplicating some logic from the twig bridge CodeExtension (or allow the HtmlDescriptor to use Twig and this extension fi available). I didn't want to pollute more this PR. So I'd suggest to try adding it into another PR :)
Actually, it's the reverse: cannot be a web link for a cli command (no context available). But IDE link works great for both web requests & cli commands:
I guess you've missed it 😄 It's already displayed on the top right: About the controller, I'd suggest to polish and add it into another PR. Right now I'm not sure where to display it and don't want to pollute more this PR. Thanks everyone for your reviews. |
| &$this->clonesCount, | ||
| ); | ||
| $this->sourceContextProvider =newSourceContextProvider($this->charset); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
this defeats dependency injection, that's why I proposed to get it through$serverDumper
| */ | ||
| finalclass RequestContextProviderimplements ContextProviderInterface | ||
| { | ||
| /** @var RequestStack */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
can be removed
nicolas-grekas commentedMar 22, 2018
@ogizanagi FYI I've forked your branch inhttps://github.com/nicolas-grekas/symfony/tree/feature/server_dump - the first commit is your PR squashed, the second are some tweaks I'd like to merge here when ready. They break the feature for now, but I think you can get the idea. If you want to take over, please tell :) |
ogizanagi commentedMar 22, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@nicolas-grekas : Here you are. The changes made to the data collector were indeed the ones I tried today, so let me explain: I also added a placeholder command in the debug bundle to easy discovery of the feature as you asked. Finally, I'm not really satisfied by the new |
fabpot commentedMar 23, 2018
@ogizanagi Do you think you will have time (perhaps this week-end) to take comments into account (if not, someone can probably take over)? I would love to merge it for 4.1. |
ogizanagi commentedMar 23, 2018
@fabpot : I've already taken all the comments into account & cherry-picked Nicolas' commit. This is already ready (at least for another round of reviews). |
fabpot left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
with minor comments
| protectedfunctionexecute(InputInterface$input,OutputInterface$output) | ||
| { | ||
| (newSymfonyStyle($input,$output))->getErrorStyle()->warning('In order to use the VarDumper server, set the debug.dump_destination config option to "tcp://%env(VAR_DUMPER_SERVER)%"'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Can you quote (") debug.dump_destination?
| ->scalarNode('dump_destination') | ||
| ->info('A stream URL where dumps should be written to') | ||
| ->example('php://stderr') | ||
| ->example('php://stderr, or tcp://%env(VAR_DUMPER_SERVER)% when using the `server:dump` command') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Can you use" instead of `?
| * added a`ServerDumper` to send serialized Data clones to a server | ||
| * added a`ServerDumpCommand` and`DumpServer` to run a server collecting | ||
| and displaying dumps on a single place with multiple formats support | ||
| * added`CliDescriptor` and`HtmlDescriptor` descriptors for`server:dump` cli and html formats support |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
CLI and HTML formats
| $availableFormats =implode(',',array_keys($this->descriptors)); | ||
| $this | ||
| ->addOption('format',null, InputOption::VALUE_REQUIRED,"The output format ($availableFormats)",'cli') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
you should usesprintf here.
ogizanagi commentedMar 23, 2018
@fabpot : Fixed & squashed (I've kept Nicolas' commit and the next one finishing it). |
fabpot commentedMar 23, 2018
Thank you@ogizanagi. |
…gh a server dumper (ogizanagi, nicolas-grekas)This PR was merged into the 4.1-dev branch.Discussion----------[VarDumper] Introduce a new way to collect dumps through a server dumper| Q | A| ------------- | ---| Branch? | 4.1 <!-- see comment below -->| Bug fix? | no| New feature? | yes <!-- don't forget updating src/**/CHANGELOG.md files -->| BC breaks? | no| Deprecations? | no <!-- don't forget updating UPGRADE-*.md files -->| Tests pass? | yes| Fixed tickets |#22987 <!-- #-prefixed issue number(s), if any -->| License | MIT| Doc PR | todo <!--highly recommended for new features-->Could also be interesting as alternate solution for#23442.Inspired by the [`ServerLogHandler`](#21080) and@nicolas-grekas's [comment](#22987 (comment)) in#22987.---## DescriptionThis PR introduces a new `server:dump` command available in the `VarDumper` component.Conjointly with a new `ServerDumper` data dumper, it allows to send serialized `Data` clones to a single centralized server, in charge of dumping them on CLI output, or in an file in HTML format.## Showcase### HTTP callsFor instance, when working on an API and dumping something, you might end up with a mix of your response and the CLI dumped version of the data you asked:```phpclass HelloController extends AbstractController{ /** *@route("/hello") */ public function hello(Request $request, UserInterface $user) { dump($request->attributes, $user); return JsonResponse::create([ 'status' => 'OK', 'message' => "Hello {$user->getUsername()}" ]); }}```<img width="732" alt="screenshot 2017-08-08 a 16 44 24" src="https://user-images.githubusercontent.com/2211145/29077731-0b2152d6-7c59-11e7-99dd-2d060a906d48.PNG">You might even get the HTML dump version [under some conditions](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php#L146-L157).Dumping to a server allows collecting dumps in a separate place:<!---->~⚠️ By swallowing the previous dumpers output, the dump data collector is not active when running the dump server. Disable swallowing if you want both.~ ➜ Dumps are still collected in the profiler thanks tof24712e### CLI callsThe best probably is (to me) that you can also debug CLI applications...<!---->...and get HTML formatted dumps:<!----><!---->hence, benefit from all the features of this format (collapse, search, ...)### HTML output at a glance<img width="831" alt="screenshot 2017-08-11 a 19 28 25" src="https://user-images.githubusercontent.com/2211145/29225513-eae349f2-7ece-11e7-9861-8cda9e80ba7f.PNG">The HTML output benefits from all the `HtmlDumper` features and contains extra informations about the context (sources, requests, command line, ...). It doesn't aim to replace the profiler for HTTP calls with the framework, but is really handy for CLI apps or by wiring it in your own web app, out of the framework usage.### CLI output at a glance<img width="829" alt="screenshot 2017-08-11 a 19 52 57" src="https://user-images.githubusercontent.com/2211145/29225482-c24afe18-7ece-11e7-8e83-d019b0d8303e.PNG">## Usage within the framework### ConfigFor instance, in your `config_dev.yml`:```yml#config_dev.ymldebug: server_dump: true```or in your `config.yml`:```yml#config.ymldebug: server_dump: '%kernel.debug%'```~~The configuration also allows to set a `host` option, but there is already a sensible default value (`tcp://0.0.0.0:9912`) so you don't have to deal with it.~~ Sinceb002175, in case you want to change the default host value used, simply use the `VAR_DUMPER_SERVER` env var.When the server is running, all dumps are collected by the server and previous dumpers ones are "swallowed" ~~by default. If you want both to collect dumps on the server AND keep previous dumpers on regular outputs, you can disable swallowing:~~<!--```ymldebug: server_dump: swallow: false```-->When the server isn't running or in case of failure to send the data clones to the server, the server dumper will delegates to the configured wrapped dumper, so dumps are displayed and collected as usual.### Running the server```bashbin/console server:dump [--format=cli|html]```#### Options- ~~The `output` option defaults to `null` which will display dumps on CLI. It accepts a file path in which dumps will be collected in HTML format.~~- The `format` option allows to switch format to use. For instance, use the `html` format and redirect the output to a file in order to open it in your browser and inspect dumps in HTML format.- ~~The default `host` value is the same as the one configured under the `debug.server_dump.host` config option, so you don't have to deal with it in most cases.~~ Sinceb002175, in case you want to change the default host value used, simply use the `VAR_DUMPER_SERVER` env var: ```bash VAR_DUMPER_SERVER=0.0.0.0:9204 bin/console server:dump ```## Manual wiringIf you want to wire it yourself in your own project or using it to inspect dumps as html before the kernel is even boot for instance:```php$host = 'tcp://0.0.0.0:9912'; // use null to read from the VAR_DUMPER_SERVER env var$cloner = new VarCloner();$dumper = new ServerDumper($host, new CliDumper());VarDumper::setHandler(function ($var) use ($dumper, $cloner) { $dumper->dump($cloner->cloneVar($var));});```## Create your own server appThe component already provides a default server app by means of the `ServerDumpCommand`, but you could also build your own by using the `DumpServer`:```php$host = 'tcp://0.0.0.0:9912'; // use null to read from the VAR_DUMPER_SERVER env var$server = new DumpServer($host);$server->start();$server->listen(function (Data $data, array $context, $clientId) { // do something});```Commits-------138dad6 [VarDumper] Some tweaks after Nicolas' commit & ServerDumperPlaceholderCommand088c52e [VarDumper] Review config to use debug.dump_destination & tweak data collector3db1404 [VarDumper] Introduce a new way to collect dumps through a server dumper
… at any time (ogizanagi)This PR was merged into the 4.1-dev branch.Discussion----------[VarDumper] Provide binary, allowing to start a server at any timeas soon as the "symfony/var-dumper" & "symfony/console" components are available.| Q | A| ------------- | ---| Branch? | master <!-- see below -->| Bug fix? | no| New feature? | yes <!-- don't forget to update src/**/CHANGELOG.md files -->| BC breaks? | no <!-- seehttps://symfony.com/bc -->| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->| Tests pass? | yes <!-- please add some, will be required by reviewers -->| Fixed tickets | N/A <!-- #-prefixed issue number(s), if any -->| License | MIT| Doc PR | TODOsymfony/symfony-docs#9474Now that#23831 is merged, there is still room for improvements we can bring during the stabilization months.Here is a first one: providing a simple CLI binary allows to easily start a server from any project (or even globally), just by having the var dumper & console packages in your deps.Commits-------eef10b1 [VarDumper] Provide binary, allowing to start a server at any time


Uh oh!
There was an error while loading.Please reload this page.
Could also be interesting as alternate solution for#23442.
Inspired by the
ServerLogHandlerand@nicolas-grekas'scomment in#22987.Description
This PR introduces a new
server:dumpcommand available in theVarDumpercomponent.Conjointly with a new
ServerDumperdata dumper, it allows to send serializedDataclones to a single centralized server, in charge of dumping them on CLI output, or in an file in HTML format.Showcase
HTTP calls
For instance, when working on an API and dumping something, you might end up with a mix of your response and the CLI dumped version of the data you asked:
You might even get the HTML dump versionunder some conditions.
Dumping to a server allows collecting dumps in a separate place:
⚠️ By swallowing the previous dumpers output, the dump data collector is not active when running the dump server. Disable swallowing if you want both.➜ Dumps are still collected in the profiler thanks tof24712eCLI calls
The best probably is (to me) that you can also debug CLI applications...
...and get HTML formatted dumps:
hence, benefit from all the features of this format (collapse, search, ...)
HTML output at a glance
The HTML output benefits from all the
HtmlDumperfeatures and contains extra informations about the context (sources, requests, command line, ...). It doesn't aim to replace the profiler for HTTP calls with the framework, but is really handy for CLI apps or by wiring it in your own web app, out of the framework usage.CLI output at a glance
Usage within the framework
Config
For instance, in dev config:
The configuration also allows to set ahostoption, but there is already a sensible default value (tcp://0.0.0.0:9912) so you don't have to deal with it.In case you want to change the default host value used, simply use the
VAR_DUMPER_SERVERenv var.When the server is running, all dumps are collected by the server and previous dumpers ones are "swallowed"
by default. If you want both to collect dumps on the server AND keep previous dumpers on regular outputs, you can disable swallowing:When the server isn't running or in case of failure to send the data clones to the server, the server dumper will delegates to the configured wrapped dumper, so dumps are displayed and collected as usual.
Running the server
Options
Theoutputoption defaults tonullwhich will display dumps on CLI. It accepts a file path in which dumps will be collected in HTML format.The
formatoption allows to switch format to use. For instance, use thehtmlformat and redirect the output to a file in order to open it in your browser and inspect dumps in HTML format.The defaulthostvalue is the same as the one configured under thedebug.server_dump.hostconfig option, so you don't have to deal with it in most cases.In case you want to change the default host value used, simply use the
VAR_DUMPER_SERVERenv var (when using the debug bundle integration):Manual wiring
If you want to wire it yourself in your own project or using it to inspect dumps as html before the kernel is even boot for instance:
Create your own server app
The component already provides a default server app by means of the
ServerDumpCommand, butyou could also build your own by using the
DumpServer: