Skip to content

[Book][Templating] refer to the VarDumper component for dump() #4446

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 20, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);

// ...
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add // ... indicating that something is missing, as controllers always have to return a response (as far as people learned until here).

}

.. 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