@@ -28,7 +28,7 @@ use instead of e.g. :phpfunction:`var_dump`. By using it, you'll gain:
2828
2929* Per object and resource types specialized view to e.g. filter out
3030 Doctrine internals while dumping a single proxy entity, or get more
31- insight on opened files with:phpfunction: `stream_get_meta_data() `;
31+ insight on opened files with:phpfunction: `stream_get_meta_data `;
3232* Configurable output formats: HTML or colored command line output;
3333* Ability to dump internal references, either soft ones (objects or
3434 resources) or hard ones (``=& `` on arrays or objects properties).
@@ -37,12 +37,6 @@ use instead of e.g. :phpfunction:`var_dump`. By using it, you'll gain:
3737 reference structure of your data;
3838* Ability to operate in the context of an output buffering handler.
3939
40- ``dump() `` is just a thin wrapper and a more convenient way to call
41- :method: `VarDumper::dump() <Symfony\\ Component\\ VarDumper\\ VarDumper::dump> `.
42- You can change the behavior of this function by calling
43- :method: `VarDumper::setHandler($callable) <Symfony\\ Component\\ VarDumper\\ VarDumper::setHandler> `:
44- calls to ``dump() `` will then be forwarded to ``$callable ``.
45-
4640By default, the output format and destination are selected based on your
4741current PHP SAPI:
4842
@@ -52,16 +46,17 @@ current PHP SAPI:
5246* On other SAPIs, dumps are written as HTML on the regular output.
5347
5448..note ::
49+
5550 If you want to catch the dump output as a string, please read the
56- `advanced documentation <advanced> ` which contains examples of it.
51+ `advanced documentation <advanced >`_ which contains examples of it.
5752 You'll also learn how to change the format or redirect the output to
5853 wherever you want.
5954
6055DebugBundle and Twig Integration
6156--------------------------------
6257
6358The ``DebugBundle `` allows greater integration of the component into the
64- Symfony full stack framework. It is enabled by default in the dev
59+ Symfony full stack framework. It is enabled by default in the* dev * and * test *
6560environement of the standard edition since version 2.6.
6661
6762Since generating (even debug) output in the controller or in the model
@@ -109,8 +104,110 @@ original value. You can configure the limits in terms of:
109104 Reading a Dump
110105--------------
111106
112- For simple variables, reading the output should be straightforward::
107+ For simple variables, reading the output should be straightforward.
108+ Here are some examples showing first a variable defined in PHP,
109+ then its dump representation:
110+
111+ ..code-block ::php
112+
113+ $var = array(
114+ 'a simple string' => "in an array of 5 elements",
115+ 'a float' => 1.0,
116+ 'an integer' => 1,
117+ 'a boolean' => true,
118+ 'an empty array' => array(),
119+ );
120+
121+ ..image ::/images/components/var_dumper/01-simple.png
122+
123+ ..note ::
124+
125+ The gray arrow is a toggle button for hidding/showing children of
126+ nested structures.
127+
128+ ..code-block ::php
129+
130+ $var = "This is a multi-line string.\n";
131+ $var .= "Hovering a string shows its length.\n";
132+ $var .= "The length of UTF-8 strings is counted in terms of UTF-8 characters.\n";
133+ $var .= "Non-UTF-8 strings length are counted in octet size.\n";
134+ $var .= "Because of this `\xE9` octet (\\xE9),\n";
135+ $var .= "this string is not UTF-8 valid, thus the `b` prefix.\n";
136+
137+ ..image ::/images/components/var_dumper/02-multi-line-str.png
138+
139+ ..code-block ::php
140+
141+ class PropertyExample
142+ {
143+ public $publicProperty = 'The `+` prefix denotes public properties,';
144+ protected $protectedProperty = '`#` protected ones and `-` private ones.';
145+ private $privateProperty = 'Hovering a property shows a reminder.';
146+ }
147+
148+ $var = new PropertyExample();
149+
150+ ..image ::/images/components/var_dumper/03-object.png
151+
152+ ..note ::
153+
154+ `#14 ` is the internal object handle. It allows comparing two
155+ consecutive dumps of the same object.
156+
157+ ..code-block ::php
158+
159+ class DynamicPropertyExample
160+ {
161+ public $declaredProperty = 'This property is declared in the class definition';
162+ }
163+
164+ $var = new DynamicPropertyExample();
165+ $var->undeclaredProperty = 'Runtime added dynamic properties have `"` around their name.';
166+
167+ ..image ::/images/components/var_dumper/04-dynamic-property.png
168+
169+ ..code-block ::php
170+
171+ class ReferenceExample
172+ {
173+ public $info = "Circular and sibling references are displayed as `#number`.\nHovering them highlights all instances in the same dump.\n";
174+ }
175+ $var = new ReferenceExample();
176+ $var->aCircularReference = $var;
177+
178+ ..image ::/images/components/var_dumper/05-soft-ref.png
179+
180+ ..code-block ::php
181+
182+ $var = new \ErrorException("For some objects, properties have special values\nthat are best represented as constants, like\n`severity` below. Hovering displays the value (`2`).\n", 0, E_WARNING);
183+
184+ ..image ::/images/components/var_dumper/06-constants.png
185+
186+ ..code-block ::php
187+
188+ $var = array();
189+ $var[0] = 1;
190+ $var[1] =& $var[0];
191+ $var[1] += 1;
192+ $var[2] = array("Hard references (circular or sibling)");
193+ $var[3] =& $var[2];
194+ $var[3][] = "are dumped using `&number` prefixes.";
195+
196+ ..image ::/images/components/var_dumper/07-hard-ref.png
197+
198+ ..code-block ::php
199+
200+ $var = new \ArrayObject();
201+ $var[] = "Some resources and special objects like the current";
202+ $var[] = "one are sometimes best represented using virtual";
203+ $var[] = "properties that describe their internal state.";
204+
205+ ..image ::/images/components/var_dumper/08-virtual-property.png
206+
207+ ..code-block ::php
208+
209+ $var = new AcmeController("When a dump goes over its maximum items limit,\nor when some special objects are encountered,\nchildren can be replaced by an ellipsis and\noptionnally followed by a number that says how\nmany have been removed; `9` in this case.\n");
113210
114- dump(array(true, 1.1, "string"));
211+ .. image :: /images/components/var_dumper/09-cut.png
115212
116213.. _Packagist :https://packagist.org/packages/symfony/var-dumper