Update (7/22/2011): dogmatic69 pointed out that you can do the same with Chrome by installing the xdebug extension. See his comment for details.
For all the Netbeans users out there, if you don’t have debugging enabled, this little “how-to” should get you stared pretty easily.
First prerequisite is to make sure you have xdebug installed and enabled for PHP.
In the php.ini you should have the following settings:
xdebug.remote_host="localhost" #or try 0.0.0.0
Make sure that the xdebug extension is enabled, of course.
(Under the [XDebug] section of php.ini, zend_extension=[path to your php_xdebug lib]).
Don’t forget to restart your web server ;)
Next we’ll install the Netbeans Fire Fox add-on.
It can be downloaded from here: https://addons.mozilla.org/en-US/firefox/addon/easy-xdebug/
As you can guess this means that FF should be your default browser, because it will need to open up once you start running the debugger.
Let’s switch to Netbeans, right click on the app of interest and navigate to “Properties”.
In the project properties window select “Run configuration”.
Project URL: http://yourhost.example.local/ (the local host name from which your app is running).
Index File: index.php (easy enough).
Double check some options in Netbeans…
Tools -> Options -> PHP tab
“PHP Interpreter” should point to the correct location of your PHP executable.
“Debugger Port” should be the same as the setting in your php.ini (xdebug.remote_port=9000)
You might want to “uncheck” the “Stop at First Line” box.
This should be it, as far as the setup goes…
You can now run a quick test:
Add a breakpoint at some line.
(You might want to add xdebug_break(); at the bottom of the file, just to be sure).
Hit Ctrl+F5 (or whatever is the command on your OS to debug the project).
If all goes well FF should open up and you should see the code execution stop at the line where you’ve set the breakpont with some debug info in the Netbeans console.
p.s. Setting up other IDE’s should be similar in the overall approach… but, as always, your mileage may vary.