sudo apt-get install php-pearPECL also requires the PHP development libraries, which have to be installed separately on Ubuntu. On many distros, such as Arch Linux, you can skip this step.
sudo apt-get install php5-devNow you're ready to get Xdebug:
sudo pecl install xdebugThis will download and compile the Xdebug module. When it finishes successfully, it will tell you where the xdebug.so module was installed, which is fine, but it also tells you to to add a line in php.ini to enable the extension. This last part is automatically output by PECL whenever it's finished compiling a module, and in this case, it's not quite right: Xdebug must actually be loaded as a Zend extension not a regular one.
To do this, you must add the following line to php.ini:
zend_extension="/path/to/xdebug.so"Use the path that PECL gave when it had finished compiling xdebug, which will be something like this:
zend_extension=/usr/lib/php5/20090626+lfs/xdebug.soIn order to enable debugging features such as stepping through code from your IDE, you'll need to configure Xdebug for remote sessions. Create the following section in the 'Module Settings' section within php.ini:
[xdebug] xdebug.remote_enable=on xdebug.remote_handler=dbgp xdebug.remote_port=9000Note that these settings assume you'll be debugging on the local machine, i.e. any address that resolves to 127.0.0.1 e.g. localhost. If you want to debug on another machine, specify it with the following additional line:
xdebug.remote_host=MACHINENAMECheck this page for a list of all of the Xdebug options that you can set in php.ini. Another thing you might want to get at this point is the 'easy Xdebug' Firefox extension as it allows you to enable and disable debug sessions from your browser (rather than just from your IDE).
Now we just need to configure Eclipse. Go to Window > Preferences, and select the Debug section within the PHP options (don't get confused with the separate Run/Debug options which we don't need to worry about here). Now select XDebug as your debugger. If you aren't using localhost for your development server, you can change that also. Leave the PHP Executable as it is, and click OK:
You can now start a debugging session from within Eclipse by right-clicking on a page, and choosing Debug As > PHP Web Page.