
That means you can stop the execution right before a critical juncture (for example, where something is crashing or producing bad data) and look at the values of all the variables and objects to make sure they are what you expect them to be.
MACGDBP COULD NOT OPEN SOCKET SOFTWARE
What is a debugger?Ī debugger is a software program that watches your code while it executes and allows you to inspect, interrupt, and step through the code.
MACGDBP COULD NOT OPEN SOCKET FREE
Readers familiar with what a debugger is and how it works should feel free to skip ahead to the "Setting Up XDebug" section. XDebug is our main recommendation for developers that want to go into hardcore debugging. Which clear the database and file cache respectively. Using Drupal, you can clear all caches with the drush command civicrm-cache-clear.Īlternatively, you can call the following two methods: You can also force the backtrace to be printed at any point in the code by adding a call to "CRM_Core_Error::backtrace() " Clearing the cache If display backtrace is enabled in Debugging options then the backtrace will be displayed when an error occurs. It can be really useful in understanding the path that was taken through code, what gets executed where, etc. BacktraceĪ backtrace is a list of all the functions that were run in the execution of the page, and the php files that contain these functions. When debug mode is enabled, you can display all the smarty variables that have been added to the page by adding &smartyDebug=1 to any URL. Go to Admin > Global config > Debugging to enable debug mode and read more about the available options. These tools are activated by adding parameters to the URL that makes up the page, e.g. It also provides shortcut methods to empty the file based cache and session variables.

Debug modeĬiviCRM has a debug mode which you can enable to give you quick access to a couple of useful diagnostic tools, including access to all the smarty variables that make up a page, and access to the backtrace (read more about backtrace below). It is a wrapper around print_r($variable) which does some clever stuff, but print_r($variable) is often all you need.įollowing your print_r() with and exit to stop the script execution at that point is often useful or necessary. Printing PHP variablesĬRM_Core_Error::debug($name, $variable = null, $log = true, $html = true) can be called to print any variable. This chapter contains some simple debugging tips and tricks to get you started and also instructions on setting up XDebug, which is the recommended debugging tool for CiviCRM when you have bugs which you are finding it really hard to squish. There are lots of options for debugging and there is lots you can do without setting up a sophisticated debugging environment. When your code isn't doing what you want it to do, it's time to debug.
