Skip to content

Latest commit

 

History

History
52 lines (34 loc) · 1.26 KB

dump-function.md

File metadata and controls

52 lines (34 loc) · 1.26 KB
title level
Dumping
intermediate

Dumping functionality

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.