debugging php suggestion

hello all -

php has been a nice language, but debugging it can be a problem. previously, i have been forced to put in a file-open at the top of the program, and then litter the program with write statements.

and to be painfully honest, i forget to remove them so the log files all get VERY large over time!

another alternative has been to create a dot-access file and just log my messages with the php error_log statement.

then came firePHP, an extension of firefox-firebug. quite nice, but firefox kept crashing on me, and firePHP was sort of clumsy to use.

this week i discovered ChromePHP - the missing link to google-chrome. with this, just a couple of lines of code, a little knowledge of the chrome "inspect-element" command, and now status messages appear in the console box!

really, how much more simple does it get?

Code:
include 'ChromePhp.php';
ChromePhp::log('hello world');
ChromePhp::log($_SERVER);
 

Quags

Administrator
Staff member
I've been able to debug some php problems using strace, while not pretty its good for the dreaded white pages.

Like:

strace -o filename php index.php

Make sure to run as the account username (not root)

Then open filename with a text editor.
 

Joe Huss

Administrator
Staff member
If you have root/Administrator access to the server, there are also several PHP Debugging modules you can choose from which will allow you to trace through a running program line by line and inspect variables as it runs and how they change. PHP Debuggers are usually used in combination with a PHP Editor which supports it. One example would be NuSphere PHP Debugger and PhpEd (http://www.nusphere.com/products/php_debugger.htm).

There are videos near the bottom of the page I linked showing demos of debugging a remote PHP website.
 
strace !? and just when i thought i knew everything, somebody suggests something i should have known about but somehow missed that discussion in kindergarden ;)

the problem i have is that often times, the debugger itself represents yet another learning curve. it took me awhile to learn the venkamp jScript debugger in firefox, and then it went away in favor of firebug.... but ever since firefox and java quit playing nicely together i switched entirely over to google-chrome.

also, since it took me long enough to master vi, i am not too eager to learn an editor just for one language.

sadly, my real hope is to switch over to ruby anyways! which means i have to start all over again... (again)
 
i would be remiss not to mention the ol' tried-and-true method: just create a dot-htaccess (.htaccess) file and put this into it:

php_flag log_errors on
php_value error_log /var/www/blah/blah/blah/marks-php-error.log
php_flag display_errors on
php_value error_reporting 6143

no more white screen!
 
Top