Development Status
Work In Progress
Active Installs
Maintainers
Download

Last updated: 2024-04-18

Works with CiviCRM 5.69 or higher.

Debug Tools

Debug Tools is a collection of tools and external libraries to facilitate the development, debug and testing of CiviCRM core / components. It is an ongoing project, and more tools might be added in the near future. Stay tuned to this repo!!

DISCLAIMER: This extensions is intended to be installed in development/staging/testing environments only and it should not be installed in production boxes. Use it in production under your own risk!!

The extension is licensed under AGPL-3.0.

Requirements

  • PHP v7.x
  • CiviCRM 5.21+

Development Resources

This extension comes out-of-the-box with these external libraries, ready to use for development/debug of CiviCRM components:

  • Adds Kint library for enhace variable debugging
  • Adds SqlFormatter library for formatting sql statements.

Kint Kint

SqlFormatter SqlFormatter

Usage

Once the libray is installed, shortcuts functions are available for debugging your CiviCRM extensions

  • q($var): prints out $var with sql format and syntax highlights
  • qd($var): prints out $var with sql format and syntax highlights
  • d($var): prints out $var in rich mode using kint
  • s($var): prints out $var in plain mode using kint
  • dd($var): calls d() and die()
  • sd($var): calls s() and die()
  • dr($var): calls d() and returns $var
  • sr($var): calls s() and returns $var

Modifiers

Modifiers are a way to change Kint output without having to use a different function. Simply prefix your call to kint with a modifier to apply it:

  • ! Expand all data in this dump automatically
  • + Disable the depth limit in this dump
  • - Attempt to clear any buffered output before this dump
  • @ Return the output of this dump instead of echoing it
  • ~ Use the text renderer for this dump

Example:

+Kint::dump($data); // Disabled depth limit
!d($data); // Expanded automatically

More examples here

Know Issues

  1. Be aware that this extension might have incompatibilities if you have already installed Drupal's Kint or Devel modules in your website

UI Debugging Tools

There are several CiviCRM UI features to help testing/debugging CiviCRM Components. To enable them please visit the menu Administer / Debug Tools / Debug Tools Settings or url: civicrm/admin/setting/debugtools.

Settings

SQL Queries Log Viewer

This feature if it's enabled, will log every single sql query made by CiviCRM in a log file. Plus, it will create a UI VIewer to make it easier the visualization of this log under the menu Administer / Debug Tools / SQL Queries Log Viewer or url: civicrm/debugtools/sqllogviewer.

It is based in CiviCRM debug setting define('CIVICRM_DEBUG_LOG_QUERY', 1); withouth need to edit civicrm.settings.php to enable it.
More info about this can be find in CiviCRM Development Guide

SQL Queries Log Viewer

Webform access Tokens

Drupal 7 only!!

This feature will add a new Tab in the Contact's Summary Page which automatically list all active Webforms in the Drupal installation, and creates unique access links to these webforms, with tokens cid and checksum already replaced to facilitate the testing of private Webform (specially Webform CiviCRM if the module is enabled).

This is useful to simulate access to different webforms as any Contact in the System. Have in mind that to test this in a proper way, you might want to open this links in a "Private Browser Window" instead of the main window you are already logged in.

Webform Access