PHPUnit is available from the PHP Extension and Application Repository (PEAR), which is a framework and distribution system for reusable PHP components. It can be installed using the PEAR Installer, as shown in the following example:
pear install PHPUnit2
Due to PEAR's version-naming standard, the PHPUnit package for PHP 5 is
called PHPUnit2
. PHPUnit
is
the name of the PHPUnit package for PHP 4 that is the topic of
"PHPUnit for PHP", later in this book.
After the installation you can find the PHPUnit source files inside your
local PEAR directory; the path is usually
/usr/lib/php/PHPUnit2
.
Although using the PEAR Installer is the only supported way to install PHPUnit, you can install PHPUnit manually. For manual installation, do the following:
Download a release archive from
http://pear.php.net/package/PHPUnit2/download
and extract it to a directory that is listed in the
include_path
of your php.ini
configuration file.
Prepare the phpunit
script:
Rename the pear-phpunit
script to
phpunit
.
Replace the @php_bin@
string in it with the
path to your PHP command-line interpreter (usually
/usr/bin/php
).
Copy it to a directory that is in your PATH
and make it executable (chmod +x phpunit
).
Replace the @package_version@
string in the
PHPUnit2/Runner/Version.php
script with the
version number of the PHPUnit release you are installing
(2.3.0
, for instance).