This documentation relates to CiviCRM version 3.2. It's not maintained anymore.
Current version of documentation.

What debugging tools are available in CiviCRM?

Aller directement à la fin des métadonnées
Aller au début des métadonnées

This page refers to outdated version of CiviCRM. Check current version of documentation.

Documentation Search

CiviCRM 3.2 Documentation

Support and Participation

Developer Resources

CiviCRM book!

Make sure to check out Understanding CiviCRM as well! You can also support this project by ordering a hard copy.

What debugging tools are available in CiviCRM?

Debugging from your browser

CiviCRM comes with several built-in debugging tools. You will need to enable the debug and backtrace options to use these tools. Once enabled, you invoke the tools via URL parameters.

You can enable debugging in: Administer CiviCRM >> Global Settings >> Debugging

Available debugging tools are:

  • Smarty Debug Window: Loads all variables available to the current page template into a pop-up window. To trigger, add &smartyDebug=1 to any CiviCRM URL query string.
  • Session Reset: Resets all values in your client session. To trigger, add &sessionReset=2
  • Directory Cleanup: Empties template cache and/or upload file folders.
    • To empty template cache (civicrm/templates_c folder), add &directoryCleanup=1
    • To remove temporary upload files (civicrm/upload folder), add &directoryCleanup=2
    • To cleanup both, add &directoryCleanup=3.

You will see a page of warnings and error messages immediately after running directory cleanup. This is normal and expected — the errors will disappear as soon as you navigate to a new CiviCRM page.

WARNING: Do not leave debugging enabled by default as it can be used to expose configuration information to unauthorized browsers.

Debugging in code

The CiviCRM framework includes a few useful debugging methods which you can insert into any codebase file to get more information about what's happening in a particular function or workflow (NB: don't forget to add require_once 'CRM/Core/Error.php'; before each of the following statements):

  • CRM_Core_Error::debug('variable_name', $variable) - readable dump of the referenced $variable to the screen
  • CRM_Core_Error::debug_var ('variable_name', $variable) - readable dump of referenced $variable to the screen and to CiviCRM.log. Add 3rd parameter false if you don't want screen output.
  • CRM_Core_Error::debug_log_message( $message, $out = false ) - dump message to CiviCRM.log. If second param is true, also echo to screen.

All logging output is written to CiviCRM.log in the configured "Temporary Files" directory (see Administer CiviCRM » Global Settings » Directories). By default this is:

<drupal root directory>/files/civicrm/upload/CiviCRM.log

Some PHP functions that may also be useful for debugging include:

  • $args=func_get_args(); - get all argument values passed in to function
  • flush(); - flush output to browser
  • Aucun

Creative Commons License
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-Share Alike 3.0 United States Licence.