Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test 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 -> Configuration and then go to Debug section. You can enable it temporarily for all users or a specific user.

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("jdoe: " . __FILE__ . " @ " . __LINE__);
debug("jdoe: \$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.

Xdebug

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".