Edit on GitHub
Jump to docs navigation

Debugging / Dumping

Note: You are currently reading the documentation for Bolt 4.0. Looking for the documentation for Bolt 5.2 instead?

If you're coding and you want to get a quick look at whatever variable or object you're trying to manipulate, you can dump its contents to the browser.

Note: Don't forget to set APP_DEBUG=1 in your .env file. Otherwise the dump() will output nothing at all.

Twig

In templates, use the following:

    {{ dump(variable) }}

The variable can be a normal variable, a Record or multiple records of Content, or other stuff.


PHP

In your code you can also dump variables and objects, like this:

    use Symfony\Component\VarDumper\VarDumper;

    VarDumper::dump($variable);

Or, using the (global) shortcut:

    dump($variable);

Like above, the $variable can be a normal variable, an object or whatever.

Note that Bolt has built-in protection for when you're tyring to 'dump' Symfony objects like $app or a variable that's \Bolt\Application.

Since these would be too large to render because of internal references and recursion, they are not expanded further.



Edit this page on GitHub
Couldn't find what you were looking for? We are happy to help you in the forum, on Slack or on Github.