Please note this article has been changed to be flexible enough to allow set-up of Xdebug for any Xamp environment (Windows/linux/mac). Also it directs you to use the Chrome Xdebug plugin so you can control when Xdebug is enabled for your application straight from Chrome without changing your php configuration and restarting Apache.
These are the different steps required to get the installation working
- Install the Xdebug PHP module in your php.ini - download the Xdebug module and enable it in PHP
- in eclipse configure the debug options to use Xdebug as default debugging tool
- Install and configure Xdebug Chrome Plugin
- Test the whole functionality from the browser
Go to the next page for detailed instructions on step 1.
- Find your current php settings by performing one of the following
- Create a page to display the phpinfo() and copy to clipboard the source of this page
- In the command line run php -i and cop the output to clipboard
- Go to http://xdebug.org/wizard.php , paste the settings collected at step 1 in the form and submit
- Follow the instructions on the Wizard and include the zend_extension entry in the php.ini . Do not restart your server yet
- Lets add the following instructions to make sure we set php to listen for the remote chrome plug
- Restart the server and inspect again the PHP info for the page or from php -i from the command line, now you should see the Xdebug module enabled there similar to the screenshot below
- in eclipse set Preferences->PHP->Debug->Installed Debuggers->select Xdebug->Configure and set Accept remote session to "any" as per images below
Make sure Eclipse is pointing to the php executable and php.ini in the PHP Executable drop down, if none available it is because ou need to tell Eclipse where it is.
- in eclipse set Preferences->PHP->Debug disable Break at first line (no need to break at first line but rather make it run until first toggle/breakpoint)
- if your project is not set as php project make sure it is by modifying the project config, instructions here
I am not going to target Firefox in this page but I am sure that by this time there is a plugin also for other browsers.
As i use Chrome i had to install the plugin available from this page.
Once installed open it and configure it so that it is enabled for your domain
- Open the Chrome settings page for extensions configuration as shown in this image
- Click on options and the Xdebug configuration page will open
- Add your localhost domain or any other local domain you are using to the list of allowed domains on this page. For instance, in my settings above the plugin is enabled only for localhost and for wallet.dev
At this point we should be set to go ... both PHP, Eclipse and your Chrome Browser and plugin are ready for a run-time debugging session.
All you need to do now is
- In Eclipse, insert a breakpoint where you want to inspect the runtime code of your php application
Notice that there is a dot next to line 2 of the code above, if you want to include or remove a breakpoin just doubleclick on the side where the dot is supposed to appear.
- Enable the Xdebug plugin on Chrome, set it to Debug
- Call the PHP page application from Chrome
- Now Eclipse should prompt you to switch to the Debug perspective, accept ... you can go back to the PHP perspective later if you want, and it will stop at your first breakpoint
You should now have all you need. If for some reason it is not working for you try to contact me from this site or google is your friend