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.
When debug mode is enabled in ownCloud, a variety of debugging features
are enabled - see debugging documentation. Set
/config/config.php to enable it:
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 ?>
<?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.
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.
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 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/remote
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/?platform=windows&q=xdebug
XDebug Helper for Chrome: https://chrome.google.com/extensions/detail/eadndfjplgieldjbigjakmdgkmoaaaoc
For debugging scripts on the command line, like
occ or unit tests, set
XDEBUG_CONFIG environment variable.