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


5 responses to “Setting up eclipse with xampp and xdebug to debug php code”

  1. Javin @ FIX Protocol Tutorials Avatar
    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 Avatar
    aamani

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

    1. jonathan Avatar

      you need to put in the url of your server; http://localhost or http://mycoolserver.com etc

  3. mmncs Avatar
    mmncs

    Hi there,

    Nice guide! Here is a complete guide on how to setup a PHP development environment in Linux Ubuntu 10.04 or 11.04 with the new Eclipse Indigo 3.7 IDE, LAMP and Debugging. Check it out here:

    http://www.mmncs.com/2011/08/how-to-install-setup-a-local-php-development-environment-in-linux-ubuntu-11-04-with-eclipse-indigo-3-7-lamp-xdebug-developer

  4. clod Avatar
    clod

    I prefer to use Codelobster IDE with xDebug

Leave a Reply