Tag Archives: apache

Recipe for debugging with XDebug, Netbeans and CakePHP

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

Cooking time:

5 – 15 mins according to taste.


  1. 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.
  2. Set the run configuration for your Netbeans project so that index file is webroot/index.php (or webroot/test.php works, I think webroot/ is the key). Open the Advanced dialog and tell it not to open the web browser, “Do Not Open Web Browser”!
  3. 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.
  4. Select Debug / Debug Project. Netbeans will start listening for the debugger.
  5. Use Firefox. Install easy XDebug plugin.
  6. Click the green bug icon at the bottom-right of Firefox. XDebug will turn on.
  7. 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.