20

If I'm used to PHP's var_dump() and print_r() to check the value of a variable, how can I evolve to inspect things in Craft where Twig's dump isn't available?

Matt Stein
  • 4,006
  • 3
  • 26
  • 57

3 Answers3

22

If you have devMode set to "true" in your config files, you can use "dump" in a twig template like this without any plug in needed:

{{ dump(myArray) }}
John Morton
  • 902
  • 6
  • 9
13

There's the dbug plugin which should give you what you are after, template side.

This plugin adds a helpful dbug method to your Craft templates. This will help you see in the dark - figure out what kind of variables you are dealing with, and what methods they implement.

Iain Urquhart
  • 388
  • 3
  • 9
7

There's a plugin called "craft inspector" https://github.com/adrianmacneil/craft-inspector that has come in handy.

{{ craft.request | inspect }}
{{ inspect(craft.request) }}
jnowland
  • 846
  • 6
  • 16