Skip to content

Commit

Permalink
feature #4446 [Book][Templating] refer to the VarDumper component for…
Browse files Browse the repository at this point in the history
… 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()
  • Loading branch information
weaverryan committed Nov 20, 2014
2 parents ed5c61f + c1eb0c5 commit 9a22865
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
31 changes: 26 additions & 5 deletions book/templating.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1487,12 +1487,33 @@ in a JavaScript string, use the ``js`` context:
Debugging
---------

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

Template parameters can then be dumped using the ``dump`` function:
// src/AppBundle/Controller/ArticleController.php
namespace AppBundle\Controller;

// ...

class ArticleController extends Controller
{
public function recentListAction()
{
$articles = ...;
dump($articles);

// ...
}
}

.. note::

The output of the ``dump()`` function is then rendered in the web developer
toolbar.

The same mechanism can be used in Twig templates thanks to ``dump`` function:

.. code-block:: html+jinja

Expand Down
2 changes: 2 additions & 0 deletions components/var_dumper/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ You can install the component in 2 different ways:
* :doc:`Install it via Composer </components/using_components>` (``symfony/var-dumper`` on `Packagist`_);
* Use the official Git repository (https://github.com/symfony/var-dumper).

.. _components-var-dumper-dump:

The dump() Function
-------------------

Expand Down

0 comments on commit 9a22865

Please sign in to comment.