Collections functions
General functions
Render functions
Theme permission functions
Resource functions

debug() function

ResourceSpace has an internal function called debug() which is defined in include/db.php

For simple or quick debugging of the system, you can pass in the debug text. The debug() function will try and write to the file specified by $debug_log_location in the config file (disabled by default) and constant debugging can be enabled by changing $debug_log to true. You can enable $debug_extended_info which will provide extended debugging information from backtrace (records pagename and calling functions).

To run the debug log for a shorter amount of time, in the ResourceSpace interface go to Admin menu -> System -> System console -> Debug log.

If the $debug_log_location is not found ensure that the permissions are open enough for the web server to read and write to it.

Typical config.php setup can be:

$debug_log          = true;
$debug_log_location = "/var/log/resourcespace/trunk.log";

While going through the code, most of the times you will either want to see if the code reaches a certain point or if a particular variable holds the value you are expecting. You need a unique identifier to help you filter down debug log lines, for example use your Subversion username.

debug("TEST.f: " . __FILE__ . " @ " . __LINE__);
debug("TEST.f: \$variable = {$variable}");

After debugging a particular part of the application always consider adding your debug code to the base. Just use a find and replace search in the file for your previously selected unique identifier.

Tracking variables

Supported version

If you have $debug_log enabled, you can now track variables from System > System console area.

Input the variable names you want tracked and how long (in minutes) they should be tracked for and Save. Click on either one of the tail options: Reload, 1s, 5s, 10s, 60s to continuosly tail the debug log.


It is expected to have to track few variables at the time but nothing should prevent you from tracking more.

Note: When the system process runs unauthenticated, it will track all users' variables.

To add a new point where variables should be tracked use the debug_track_vars function.

debug_track_vars('end@setup_user', get_defined_vars());

Please note, sometimes you may instead want to use $GLOBALS instead of the local defined variables.


Xdebug is a PHP extension which provides debugging and profiling capabilities. It can be integrated into various IDEs such as Sublime Text and Visual Studio Code.

Using a proper debugger like Xdebug can be very useful for stepping through code to see precisely where how you get to an error or for viewing the content of variables at run time.

Depending on the IDE you are using Xdebug can be enabled as long as Xdebug is installed. You can check to see if it is installed by running the phpinfo() function and looking for the text "with Xdebug".