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

This Post Has 5 Comments

  1. Javin @ FIX Protocol Tutorials

    Nice article , just to add I would suggest start up script to put JVM debug parameter and use a variable e.g. isDebugEnabled and also REMOTE_DEBUG_PORT in the script and export this variable when you want to remote debug your Java application. This will be very handy and will require just one time setup work.

    Thanks
    Javin
    How to setup remote debugging in Eclipse

  2. aamani

    Which url we need to use in step 6.
    Is it “/applications/xampp/”

Leave a Reply