Skip to content


Subversion checkout URL

You can clone with
Download ZIP
The PHP Unit Testing framework.
Failed to load latest commit information.
PHPUnit Fix data serialization when using process isolation (closes #614)
Tests Fixed tests on windows
build Delete.
.gitattributes Make the output of git-diff and git-grep more useful for PHP sourcefi…
.gitignore Refactor build system.
ChangeLog.markdown Prepare release.
LICENSE Bump copyright year.
README.markdown Add links to French documentation.
build.xml Also check tests for coding standard violations.
package.xml Prepare release.
phpunit.bat Fixed .bat files to correctly set environment variables without double



PHPUnit is the de-facto standard for unit testing in PHP projects. It provides both a framework that makes the writing of tests easy as well as the functionality to easily run the tests and analyse their results.


  • PHPUnit 3.6 requires PHP 5.2.7 (or later) but PHP 5.4.0 (or later) is highly recommended.
  • PHP_CodeCoverage, the library that is used by PHPUnit to collect and process code coverage information, depends on Xdebug 2.0.5 (or later) but Xdebug 2.1.3 (or later) is highly recommended.


PHPUnit should be installed using the PEAR Installer, the backbone of the PHP Extension and Application Repository that provides a distribution system for PHP packages.

Depending on your OS distribution and/or your PHP environment, you may need to install PEAR or update your existing PEAR installation before you can proceed with the following instructions. sudo pear upgrade PEAR usually suffices to upgrade an existing PEAR installation. The PEAR Manual explains how to perform a fresh installation of PEAR.

The following two commands (which you may have to run as root) are all that is required to install PHPUnit using the PEAR Installer:

pear config-set auto_discover 1
pear install

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


The documentation for PHPUnit is available in different formats:


The #phpunit channel on the Freenode IRC network is a place to chat about PHPUnit.

Using PHPUnit From a Git Checkout

The following commands can be used to perform the initial checkout of PHPUnit and its dependencies from Git:

mkdir phpunit && cd phpunit
git clone git://
git clone git://
git clone git://
git clone git://
git clone git://
git clone git://
git clone git://
git clone git://
git clone git://
git clone git://
git clone git://

The dbunit, php-code-coverage, php-file-iterator, php-text-template, php-timer, php-token-stream, phpunit, phpunit-mock-objects, phpunit-selenium, phpunit-story, and php-invoker directories need to be added to the include_path.

In addition to the checkouts listed above, the YAML component that is provided by the Symfony project is required:

pear install

The phpunit/phpunit.php script can be used to invoke the PHPUnit test runner.

The following commands can be used to check out the appropriate branches for PHPUnit 3.6:

cd phpunit && git checkout 3.6 && cd ..
cd dbunit && git checkout 1.1 && cd ..
cd php-code-coverage && git checkout 1.1 && cd ..
cd phpunit-mock-objects && git checkout 1.1 && cd ..
cd phpunit-selenium && git checkout 1.1 && cd ..
Something went wrong with that request. Please try again.