Skip to content

Commit 9a22865

Browse files
committed
feature #4446 [Book][Templating] refer to the VarDumper component for dump() (xabbuh)
This PR was merged into the 2.6 branch. Discussion ---------- [Book][Templating] refer to the VarDumper component for dump() | Q | A | ------------- | --- | Doc fix? | no | New docs? | no | Applies to | 2.6+ | Fixed tickets | Commits ------- c1eb0c5 refer to the VarDumper component for dump()
2 parents ed5c61f + c1eb0c5 commit 9a22865

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

book/templating.rst

+26-5
Original file line numberDiff line numberDiff line change
@@ -1487,12 +1487,33 @@ in a JavaScript string, use the ``js`` context:
14871487
Debugging
14881488
---------
14891489

1490-
When using PHP, you can use :phpfunction:`var_dump` if you need to quickly find
1491-
the value of a variable passed. This is useful, for example, inside your
1492-
controller. The same can be achieved when using Twig thanks to the Debug
1493-
extension.
1490+
When using PHP, you can use the
1491+
:ref:`dump() function from the VarDumper component <components-var-dumper-dump>`
1492+
if you need to quickly find the value of a variable passed. This is useful,
1493+
for example, inside your controller::
14941494

1495-
Template parameters can then be dumped using the ``dump`` function:
1495+
// src/AppBundle/Controller/ArticleController.php
1496+
namespace AppBundle\Controller;
1497+
1498+
// ...
1499+
1500+
class ArticleController extends Controller
1501+
{
1502+
public function recentListAction()
1503+
{
1504+
$articles = ...;
1505+
dump($articles);
1506+
1507+
// ...
1508+
}
1509+
}
1510+
1511+
.. note::
1512+
1513+
The output of the ``dump()`` function is then rendered in the web developer
1514+
toolbar.
1515+
1516+
The same mechanism can be used in Twig templates thanks to ``dump`` function:
14961517

14971518
.. code-block:: html+jinja
14981519

components/var_dumper/introduction.rst

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ You can install the component in 2 different ways:
2020
* :doc:`Install it via Composer </components/using_components>` (``symfony/var-dumper`` on `Packagist`_);
2121
* Use the official Git repository (https://github.com/symfony/var-dumper).
2222

23+
.. _components-var-dumper-dump:
24+
2325
The dump() Function
2426
-------------------
2527

0 commit comments

Comments
 (0)