Debugging
Debugging HTML and templates
By default ownCloud caches HTML generated by templates. This may prevent changes to app templates, for example, from being applied on page refresh. To disable caching, see Debug mode.
Debugging Javascript
By default all JavaScript files in ownCloud are minified (compressed) into a single file without whitespace. To prevent this, see Debug mode.
Debug mode
When debug mode is enabled in ownCloud, a variety of debugging features
are enabled - see debugging documentation. Set debug
to true
in
/config/config.php to enable it:
Debugging variables
You should use exceptions if you need to debug variable values manually, and not alternatives like trigger_error() (which may not be logged), e.g.,:
<?php throw new \Exception( "\$user = $user" ); // should be logged in ownCloud ?>
not:
<?php trigger_error( "\$user = $user" ); // may not be logged anywhere ?>
To disable custom error handling in ownCloud (and have PHP and your Web server handle errors instead), see Debug mode.
Identifying errors
ownCloud uses custom error PHP handling that prevents errors being printed to Web server log files or command line output. Instead, errors are generally stored in ownCloud’s own log file, located at: /data/owncloud.log.
Using alternative app directories
It may be useful to have multiple app directories for testing purposes, so you can conveniently switch between different versions of applications. See the configuration file documentation for details.
Using a PHP debugger (XDebug)
Using a debugger connected to PHP allows you to step through code line by line, view variables at each line and even change values while the code is running. The de-facto standard debugger for PHP is XDebug, available as an installable package in many distributions. It just provides the PHP side however, so you will need a frontend to actually control XDebug. When installed, it needs to be enabled in php.ini, along with some parameters to enable connections to the debugging interface:
XDebug will now (when activated) try to connect to localhost on port 9000, and will communicate over the standard protocol DBGP. This protocol is supported by many debugging interfaces, such as the following popular ones:
-
vdebug - Multi-language DBGP debugger client for Vim
-
SublimeTextXdebug - XDebug client for Sublime Text
-
PhpStorm - in-built DBGP debugger
For further reading, see the XDebug documentation: http://xdebug.org/docs/step_debug
Once you are familiar with how your debugging client works, you can
start debugging with XDebug. To test ownCloud through the web interface
or other HTTP requests, set the XDEBUG_SESSION_START
cookie or POST
parameter. Alternatively, there are browser extensions to make this easy:
-
XDebug for Firefox: https://addons.mozilla.org/en-US/firefox/search/?q=xdebug
-
XDebug Helper for Chrome: https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc
For debugging scripts on the command line, like occ
or unit tests, set
the XDEBUG_CONFIG
environment variable.