PHPUnit and Xdebug on Ubuntu Karmic

This is just a quick post to advise anyone who may be using PHPUnit and Xdebug together on Ubuntu Karmic. If you try to upgrade to PHPUnit 3.4.6 and you’re using the php5-xdebug Ubuntu package (which is Xdebug 2.0.4), you may get output that looks like this:

$ sudo pear upgrade phpunit/PHPUnit
Did not download optional dependencies: pear/Image_GraphViz, pear/Log, use --alldeps to download automatically
phpunit/PHPUnit can optionally use package "pear/Image_GraphViz" (version >= 1.2.1)
phpunit/PHPUnit can optionally use package "pear/Log"
phpunit/PHPUnit can optionally use PHP extension "pdo_sqlite"
phpunit/PHPUnit requires PHP extension "xdebug" (version >= 2.0.5), installed version is 2.0.4
No valid packages found
upgrade failed

There are two ways to deal with this situation. First off, note that the newer Xdebug 2.0.5 version includes several bugfixes including one related to code coverage reporting. That said, if you still want to continue using the php5-xdebug package anyway, you can force the upgrade by having the PEAR installer ignore dependencies like so:

sudo pear upgrade -n phpunit/PHPUnit

The other method involves installing Xdebug 2.0.5. First, if you have the php5-xdebug package, remove it.

sudo apt-get remove php5-xdebug

Next, use the PECL installer to install Xdebug. This requires that you have the php5-dev package installed so that the extension can be compiled locally.

sudo apt-get install php5-dev
sudo pecl install xdebug

At this point, create the file /etc/php5/conf.d/xdebug.ini if it doesn’t already exist and populate it with these contents:

zend_extension=/usr/lib/php5/20060613/xdebug.so

Then bounce Apache so that the new extension will be loaded.

sudo apache2ctl restart

That’s it. Hope someone finds this helpful.

5 Comments

  1. [...] This post was mentioned on Twitter by Ed Finkler and Matthew Turland, topsy_top20k. topsy_top20k said: New blog post: PHPUnit and Xdebug on Ubuntu Karmic http://bit.ly/7r5zh8 [...]

  2. Social comments and analytics for this post…

    This post was mentioned on Twitter by elazar: New blog post: PHPUnit and Xdebug on Ubuntu Karmic http://bit.ly/7r5zh8

  3. [...] Turland has put together a guide for getting PHPUnit and Xdebug up and working on one of the latest Ubuntu releases (Karmic) to [...]

  4. Ubuntu deb packages are handy for installing php core extensions such as database drivers, but the pecl and pear installers are better at doing their own job. This is the case.

  5. [...] Turland has put together a guide for getting PHPUnit and Xdebug up and working on one of the latest Ubuntu releases (Karmic) to [...]