PHPUnit

What PHPUnit is
PHPUnit is a free testing framework for PHP with a command-line runner for running tests and selecting suites. Its assertions cover return values, exceptions, side effects, output, error logs, files, JSON, and XML. Tests can be organized through filesystem structure or XML configuration, and can use data providers, dependencies, stubs, and mock objects. The framework documents code coverage reports in HTML and JSONL formats, together with JUnit and TeamCity logging configuration. For flaky tests, PHPUnit supports repeating or retrying runs through attributes and command-line options. Installation is available as a PHAR or as a Composer development dependency. PHPUnit 13 is the current stable major version and requires PHP 8.4 or later. Bug-fix support for PHPUnit 13 is listed through February 4, 2028, with its end-of-life date undetermined. Documentation is available for supported versions 8.5 through 13.4, and the getting-started guide covers writing and running simple unit tests. PHPUnit supports Linux, macOS, Windows, and self-hosted use; documentation also describes verifying PHAR releases.
Who it suits
PHPUnit suits PHP developers who want to write and run unit tests from the command line. Version 13 requires PHP 8.4 or later, while documentation is provided for versions 8.5 through 13.4.
What it does well
- Free to download as a PHAR or install with Composer.
- Supports data providers, dependencies, stubs, and mocks.
- Coverage reports are available in HTML and JSONL.
- Can repeat or retry flaky tests.
- Documentation covers multiple supported versions.
What to know first
- PHPUnit 13 requires PHP 8.4 or later.
- The end-of-life date for PHPUnit 13 is undetermined.
Plans
| Plan | Billed and limits | Price |
|---|---|---|
| PHPUnit | PHP testing framework · download as PHAR or install per project with Composer | Free |
As phpunit.de lists them, read 4 Oct 2026. The maker's own page has the final word.
Getting started
- Visit https://phpunit.de/ and choose the documentation for your supported version.
- Install PHPUnit as a PHAR or as a Composer development dependency.
- Use the getting-started guide to write simple unit tests for PHP code.
- Run tests and select test suites with the command-line runner.
Verdict
PHPUnit offers a broad set of test assertions, organization options, and reporting formats for PHP projects. Check the PHP 8.4 requirement before choosing the current stable major version.
Questions
How much does PHPUnit cost?
The listed plan is free. It has a free plan and no free trial.
Which programming language does it support?
PHP is the listed supported language.
What PHP version does PHPUnit 13 require?
The current stable major version, PHPUnit 13, requires PHP 8.4 or later.
How can I install it?
You can install PHPUnit as a PHAR or as a Composer development dependency.
Does PHPUnit support mocks and parameterized cases?
Yes. It supports test stubs and mock objects, as well as data providers.
Who maintains PHPUnit?
Sebastian Bergmann is its creator and lead maintainer.
Facts from PHPUnit's own pages
- Assertions
- The manual documents assertions for values, exceptions, side effects, output, files, JSON, and XML. · docs.phpunit.de, 4 Oct 2026
- Audience
- The getting-started guide teaches writing simple unit tests and running them for PHP code. · phpunit.de, 4 Oct 2026
- Code coverage
- The manual documents code coverage reports in HTML and JSONL formats. · docs.phpunit.de, 4 Oct 2026
- Coverage and reports
- The manual documents code coverage, HTML and JSONL coverage reports, and JUnit and TeamCity logging configuration. · docs.phpunit.de, 3 Oct 2026
- Current PHP requirement
- The current stable major version is PHPUnit 13, which requires PHP 8.4 or later. · phpunit.de, 3 Oct 2026
- Current release
- PHPUnit 13 is listed as the current stable major version. · phpunit.de, 4 Oct 2026
- Flaky tests
- PHPUnit supports repeating and retrying tests, including through attributes and command-line options. · docs.phpunit.de, 3 Oct 2026
- Headquarters
- The site's legal notice lists Sebastian Bergmann at an address in Siegburg, Germany. · phpunit.de, 3 Oct 2026
- Installation
- PHPUnit 13 can be downloaded as a PHAR archive or installed as a per-project development dependency with Composer. · phpunit.de, 4 Oct 2026
- Maintainer
- The site identifies Sebastian Bergmann as responsible for the website and its editorial content, with an address in Siegburg, Germany. · phpunit.de, 4 Oct 2026
- Maintainer and sponsorship
- Sebastian Bergmann is PHPUnit's creator and lead maintainer, and says he reviews and validates every change; sponsorship does not buy influence over the roadmap. · phpunit.de, 3 Oct 2026
- PHP requirement
- PHPUnit 13 requires PHP 8.4 or later. · phpunit.de, 4 Oct 2026
- Purpose
- PHPUnit is a testing framework for PHP. · phpunit.de, 4 Oct 2026
- Release support
- PHPUnit 13 receives bug-fix support through February 4, 2028; its end-of-life date is undetermined. · phpunit.de, 3 Oct 2026
- Security
- The getting-started page links to documentation for verifying PHPUnit PHAR releases. · phpunit.de, 4 Oct 2026
- Security verification
- The getting-started page directs users to documentation for verifying PHPUnit PHAR releases. · phpunit.de, 3 Oct 2026
- Support policy
- PHPUnit 13 bugfix support is listed through February 4, 2028, and its end-of-life date is to be determined. · phpunit.de, 4 Oct 2026
- Support versions
- The site provides documentation for supported PHPUnit versions 8.5 through 13.4. · phpunit.de, 4 Oct 2026
- Test assertions
- The manual covers tests for return values, exceptions, side effects, output, and error log output. · docs.phpunit.de, 3 Oct 2026
- Test doubles
- The framework supports test stubs and mock objects. · docs.phpunit.de, 4 Oct 2026
- Test execution
- PHPUnit provides a command-line test runner for running tests and selecting test suites. · docs.phpunit.de, 4 Oct 2026
- Test organization
- Tests can use data providers and dependencies, and can be organized using the filesystem or XML configuration. · docs.phpunit.de, 3 Oct 2026
- Test stability
- PHPUnit supports repeating and retrying tests to work with flaky tests. · docs.phpunit.de, 4 Oct 2026
Where PHPUnit stands on Freedom251
- Unit Testing#9 of 32
- Unit Testing Frameworks#13 of 32
