PHPUnit is now available through the PHP Extensions and Libraries (PEAE). PEAR is a framework and distribution system for reusable PHP components. Installing PHPUnit is available via the PEAR installer command:
pear install PHPUnit2
According to PEAR's version naming standards, the PHPUnit package for PHP5 is called PHPUnit2. PHPUnit is a package suitable for PHP4, which will be mentioned in the chapter "Using PHPUnit in PHP4" later in this book.
Only after installation, the source code of PHPUnit can be found in the local PEAR directory. The path is usually /usr/lib/php/PHPUnit2.
Although using the PEAR installer is the only installation method supported by PHPUnit, you can still install it manually. To install manually, please refer to the following methods:
1. Download the PHPUnit release package from http://pear.php.net/package/PHPUnit2/download , then unzip it and make sure the directory is in the include_path defined in php.ini.
2. Prepare the phpunit script
a. Rename the pear-phpunit script to phpunit
b. Rename all @php_bin@ in the script to the directory where the PHP command line interpreter is located (usually /usr/bin/php).
c. Copy this script to a directory included in the PATH environment variable, and change the file attribute to executable (chmod +x phpunit).
3. Replace all @package_version@ strings in the PHPUnit2/Runner/Version.php script with your installed PHPUnit version (such as 2.3.0).