Recently I needed to install PHPUnit to write some test for an application I was working on. Here I will describe how I installed it on Ubuntu.

First of all, you’ll need to install PEAR, which provides a distribution system for PHP packages, and is shipped with every release of PHP since version 4.3.0.

apt-get install php5-dev php-pear

Subsequently you’ll install PHPUnit through the PEAR installer. To do that run the following:

pear upgrade PEAR
pear config-set auto_discover 1
pear install pear.phpunit.de/PHPUnit

After the installation you can find the PHPUnit source files inside your local PEAR directory; the path is usually /usr/lib/php/PHPUnit.

5 comments so far

Add Your Comment
  1. Wylie Beasley

    CakePHP development make installation and use of it extremely easy. Furthermore, Cake takes less time coding, which means less cost as well.

  2. Richard Larson

    What is the difference between installing via pear rather than just doing this?:

    apt-get install phpunit

    I always use apt-get to install it. When I install it from apt it actually does install it through pear and seems to bring in all the dependencies and also set up all the pear channels automatically for phpunit, etc. So it’s just a single command to install it. Why do I always see everyone do it explicitly through pear? Am I missing something?

  3. Carlos Perea

    Thank you! It worked flawlessly in Linux Mint 14.

  4. neomaster


    It is very short way of installing phpunit but when I tried on ubuntu-12.04 (32 bit) last command (pear install pear.phpunit.de/PHPUnit) is generating below error:

    invalid package name/package file “pear.phpunit.de/PHPUnit”

  5. Mischa ter Smitten

    That’s because the PEAR way of installing is not supported anymore. See: