Take the 2-minute tour ×

How do you debug PHP? Just with debug-prints in your script? Or is it worth installing XDebug? Is there any better debugging possiblity?

share|improve this question
Do yourself a favor and debug PHP using XDebug with Netbeans. –  Jason Holland Jul 18 '12 at 13:40
I really enjoy debugging PHP with RADPHP/HTML5Builder from Embarcadero, but it's not free. I've also used Netbeans and it's great. –  Warren P Mar 22 '13 at 2:03
add comment

3 Answers

There are some alternatives to consider from (licensed, trail, open-source). Start with choosing one and look at debugging techniques for PHP.

I have listed references below to look at all mentioned tips:

share|improve this answer
add comment

Xdebug is the easiest option and many IDEs have very simple setup procedures because it's so common and useful. I would not dream of coding anything in PHP without it. Not only can you see what the variables are, you can watch them change as you step forwards, then set conditional breakpoints so that e.g. you only stop a loop when a variable matches the value you're interested in. You can also look at different parts of the program during the same page load and set particular variables onto a watch list so you can easily see how they change whilst ignoring the others.

There's just no way to get enough print_r() calls into your script (as well as take them out again afterwards) to be that useful without sacrificing huge amounts of time.

share|improve this answer
Well, then I probably should try installing xdebug again. There's a Ubuntu package with xdebug. What I didn't like is that it listens on all interfaces on port 9000. I couldn't restrict it to localhost. I ran a script in Eclipse and it looked like it's debugging it like a php-cli script, not a webpage. I didn't get any debug messages / break points when opening the page in the Eclipse browser. I'll have a look at it again. Thanks again for your reply. –  chris Jul 18 '12 at 13:13
This'll help a lot: xdebug.org/wizard.php It's possible to set it up so it looks like it's working, but without a couple of important settings. –  Matt Gibson Jul 18 '12 at 13:42
add comment

Yes, Xdebug is an good option for debugging PHP Code. I give you four class of debugging PHP Code.

I often use some combined tools to debugging PHP fastest.

There is four class for debugging php.

First is simple debug, you can use php funciton ex. var_dump, print_r.

Second is dll debug, you can use external dll library for debuging ontime i.e. xdebug, zend_debug.

Third is framework debug, some tool is design specially for its framework i.e. zend_log, cakephp logging, symfony logging.

Fourth is php debug, it's is written in plain php, no belong to any framework i.e. Kint, Log.Vkit, dbug.

You can try all class. After a period time, you can combine some tools in them that is suitable for yourself.

share|improve this answer
add comment

Your Answer


