@@ -45,6 +45,52 @@ The advantages of this function are:
4545so can you also use it directly.
4646You can change the behavior of this function by calling
4747:method: `VarDumper::setHandler($callable) <Symfony\\ Component\\ VarDumper\\ VarDumper::setHandler> `:
48- calls to ``dump() `` will then be forwarded to ``$callable ``, given as first argument.
48+ calls to ``dump() `` will then be forwarded to ``$callable ``.
49+
50+ Where does the output go?
51+ -------------------------
52+
53+ If you read the advanced documentation, you'll learn how to change the
54+ format or redirect the output to wherever you want.
55+
56+ By default, these are selected based on your current PHP SAPI:
57+
58+ - on the command line (CLI SAPI), the output is written on `STDERR `. This
59+ can be surprising to some because this bypasses PHP's output buffering
60+ mechanism. On the other hand, this give the possibility to easily split
61+ dumps from regular output by using pipe redirection.
62+ - on other SAPIs, dumps are written as HTML on the regular output.
63+
64+ DebugBundle and Twig integration
65+ --------------------------------
66+
67+ The `DebugBundle ` allows greater integration of the component into the
68+ Symfony full stack framework. It is enabled by default in the dev
69+ environement of the standard edition since version 2.6.
70+
71+ Since generating (even debug) output in the controller or in the model
72+ of your application may just break it by e.g. sending HTTP headers or
73+ corrupting your view, the bundle configures the `dump() ` function so that
74+ variables are dumped in the web debug toolbar.
75+
76+ But if the toolbar can not be displayed because you e.g. called `die `/`exit `
77+ or a fatal error occurred, then dumps are written on the regular output.
78+
79+ In a Twig template, two constructs are available for dumping a variable.
80+ Choosing between both is generally only a matter of personal taste:
81+
82+ - `{% dump foo.bar %} ` is the way to go when the original template output
83+ shall not be modified: variables are not dumped inline, but in the web
84+ debug toolbar.
85+ - on the contrary, `{{ dump(foo.bar) }} ` dumps inline and thus may or not
86+ be suited to your use case (e.g. you shouldn't use it in an HTML
87+ attribute or a `script ` tag).
88+
89+ Reading a dump
90+ --------------
91+
92+ For simple variables, reading the output should be straightforward::
93+
94+ dump(array(true, 1.1, "string"));
4995
5096.. _Packagist : https://packagist.org/packages/symfony/var-dumper
0 commit comments