It took me a while to get this working so I didn’t spend all my time debugging the debugging. I’ll be brief and hope that you don’t run into any problems following this : )
- XDebug latest (new version out I notice, must try that soon)
- PHP 5.2 or 5.3
- Netbeans 7.1
- Local install of Apache HTTPD server
- CakePHP 1.3
- Windows 7
5 – 15 mins according to taste.
- Add XDebug extension to your php.ini file. Note with PHP 5.2 you must use zend_extension_ts and with PHP 5.3 you must use zend_extension. Restart Apache.
- Set the run configuration for your Netbeans project so that index file is
webroot/test.phpworks, I think
webroot/is the key). Open the Advanced dialog and tell it not to open the web browser, “Do Not Open Web Browser”!
- Open Netbeans / Options / PHP / General / Debugging and check “Stop at first line”. Haven’t had much success otherwise. Check “Watches and Balloon Evaluations” if you want but this sometimes causes problems.
- Select Debug / Debug Project. Netbeans will start listening for the debugger.
- Use Firefox. Install easy XDebug plugin.
- Click the green bug icon at the bottom-right of Firefox. XDebug will turn on.
- Refresh the page on your site and you should be able to step through your scripts and set breakpoints as necessary.
You might find in some situations Netbeans loses the connection to XDebug. Closing and reopening Netbeans is usually necessary to get it working again, but nevertheless, this is the best experience I’ve had debugging PHP so far. Comments and suggestions welcome.