Debugging Tips
From Habari Project
Habari provides some features that allow you to better debug things when problems arise. Here are some tips that will help speed your progress.
Debug Mode
Normally, Habari runs in a silent mode, where error details are not displayed. This protects your site's code and data from potential exposure if problems arise.
Habari has a "debug mode" that will cause the error details to be displayed with any error.
To enable this mode, edit the config.php file for your site and add this line:
define('DEBUG', true);
Any error that occurs will have a complete call stack displayed, which is very useful for tracing execution through the code that led to the error.
Utils::debug
When tracing through the Habari source code, sometimes it's useful to display the value of a variable at a certain place in execution. Normally, you might use the PHP command print_r() to output this information, but without some extra markup, this may cause some formatting issues, and doesn't provide all of the information that might be useful for debugging.
Instead, Habari provides the Utils::debug command, which produces output like print_r(), but formats it nicely and provides a call stack. The call stack can be expanded to show the functions that were executed to arrive at that point in code. Each of the functions displayed also shows the parameter types passed to that function, and if you click on them they will toggle, revealing the parameter values.
To call Utils::debug(), you may pass zero or more parameters, the values of each will appear in the output along with their type information:
Utils::debug($foo, $bar, $baz);
