dpm(), other devel functions, and you

Last updated on
11 March 2021

Drupal 7 will no longer be supported after January 5, 2025. Learn more and find resources for Drupal 7 sites

This documentation needs work. See "Help improve this page" in the sidebar.

Have you ever tried to add something to a module, and cannot figure out why the data won't display?

You could have a typo, or could be using the wrong function to access the data, token or variable you are trying to envoke. 

Devel gives you debugging tools that you can add inline to your code. Best practice suggests only using during development, using on production sites may impact site performance.

These are much more helpful than just using basic php to output variables directly, and Devel even knows to output these things to the official message area in your theme. 

Basic usage: in the php file, place the variable you're curious about inside the function call. ie:

dpm($variableInQuestion);

Depending on which Devel function you use, you'll get a variety of output messages, directly on the page in question. Once you are finished debugging, remove these extra functions from your code. 

Here are the functions to add to your code that will appear on your pages when Devel is enabled.

Function Name Function Description API 7.x API 8.x
dpm() Prints a variable to the 'message' area of the page. dpm dpm
dvm() Displays a drupal_var_export() variable to the 'message' area of the page. dvm dvm
dpr() Pretty-print a variable to the browser (no krumo). dpr dpr
dvr() Like dpr(), but uses drupal_var_export() instead. dvr dvr
kpr() Use Krumo to print readable output kpr kpr
dargs() Prints arguments passed into the current function (variable name and value) dargs dargs
dd() Drupal Debug - outputs value to a file, drupal_debug.txt, in the temp directory.  drupal_debug dd
ddebug_backtrace() Print function call stack ddebug_backtrace ddebug_backtrace

Read more at:

Help improve this page

Page status: Needs work

You can: