Setting up eclipse with xampp and xdebug to debug php code

Setting up eclipse with xampp and xdebug to debug php code.

This post will show you how to setup eclipse on your mac to work with xdebug inside XAMPP. This setup will allow you to step through your code as it runs, line by line, add breakpoints in your eclipse code, view variable values as your code is running and all the other cool things that xdebug lets you do.

eclipse with xampp and xdebug

Eclipse with XAMPP and xDebug

  • install eclipse
  • install xampp with xdebug
  • open a project [or create a new one]
  • goto elipse > preferences > php > servers
  • Click ‘add new’
  • type in a name + put in the url you use to view (eg http://localhost/mysite)
  • click the ‘browse’ button and navigate to where your source code is (eg /home/users/username/development/mysite)
  • click ‘next’
  • make sure to pick xDebug as the debugger.
  • click ‘next’
  • in the ‘path mapping’ section, click ‘add’
  • fill in your details
  • eg: path on server = /
  • eg: path in workspace = /mysite
  • hit finish

You can now use eclipse with xampp and xdebug to debug your php code.
if you have set your document root of your XAMPP to be the same place you save your projects to then you can set breakpoints, etc and have the code open at the correct place without having to do mappings =)

Sources: https://eclipse.org/pdt/documents/XDebugGuideForPDT2.0.pdf