This thread introduces some basic tips about configuring PHP and Apache to give useful information about Joomla bugs. Most installations of Apache and PHP will not, by default, give this information, but this can easily be changed. Why enable reporting? Because this information will indicate where PHP found a problem and helps us resolve the cause of the problem.
Your Current Settings
You may have error logging already. To check using Joomla!1.5 , in the administrator application select Help -> System Info. On the submenu, select PHP Information and search for error_log, error_reporting, and display_errors . Both the local and global settings are show, but it is the local settings that matter when working with Joomla. You should also note the Configuration File (php.ini) Path for future reference.
How to Change the Settings
As with anything there are many ways to enable PHP reporting of errors and warnings, and the tips below represent the way that I like to work. Suggestions are welcomed.
Using Apache's 2.0 virtual hosting I have several sites on my local system, each with their own log files. With these settings, all PHP errors are both displayed and logged to a file. The php_flag and php_value directives can also be placed in an .htaccess file if the webserver permits the overriding of options.
Code: Select all
<VirtualHost *:80>
ServerName joomla
DocumentRoot /var/www/domains/joomla/html
ErrorLog /var/www/domains/joomla/error_log
CustomLog /var/www/domains/joomla/access_log common
php_flag display_errors on
php_value error_reporting 6143
php_flag log_errors on
php_value error_log /var/www/domains/joomla/php_log
</VirtualHost>
Code: Select all
error_reporting = E_ALL
;error_reporting = E_ERROR
display_errors = On
;display_errors = Off
... and so on
Watching the Log File
The log file can easily be watched using a utility called tail which comes natively with most *nix distributions, including Linux and Mac OS X. Windows users will need to install this utility ( cygwin or unxutils ). When used, the PHP log file will look something like this:
This information is incredibly useful to developers because it indicates exactly where PHP detected a problem. Not all problems will result with additional entries in the log file ( poor code logic, JavaScript/Browser issues ), but most will.Toby-Patterson:html $ tail -f /var/www/domains/joomla/php_log &
[27-Mar-2007 22:36:35] PHP Notice: Trying to get property of non-object in /private/var/www/domains/joomla/html/components/com_content/helpers/content.php on line 347
[27-Mar-2007 22:36:35] PHP Notice: Trying to get property of non-object in /private/var/www/domains/joomla/html/components/com_content/helpers/content.php on line 339
Resources
PHP Configuration References:
http://www.php.net/manual/en/configuration.changes.php
http://www.php.net/manual/en/ini.php#ini.list
http://www.php.net/error_reporting
http://www.php.net/manual/en/ref.errorfunc.php
Apache Configuration References:
http://forum.joomla.org/index.php?topic=79277.0
http://httpd.apache.org/docs/2.0/mod/co ... owoverride
Utility References:
http://www.cygwin.com/
http://unxutils.sourceforge.net/
Final Thoughts
Again, this is merely an introduction and suggestions are welcomed.
Happy Debugging,
tcp
Note to moderators: Please feel free to edit this post with additional suggestions or links.
--edit March 28th - links to cygwin and unxutils