PHP test suites are easier to keep reliable when the runner matches both your PHP branch and the project style you use every day. Fedora packages current PHPUnit releases as versioned commands, so you can install PHPUnit on Fedora with DNF, keep older major versions beside the newest runner, and avoid adding a third-party repository just for a test command.
Fedora 44 currently ships PHP 8.5, while Fedora 43 ships PHP 8.4. Both satisfy PHPUnit 13, and Fedora also keeps older phpunit12, phpunit11, and legacy compatibility packages available for projects that cannot upgrade their test suite yet.
Install PHPUnit on Fedora
The Fedora repository method is the default path for a system-wide PHPUnit command. DNF installs the PHP CLI runtime and PHPUnit dependency packages automatically, then updates the runner through normal Fedora package upgrades.
Choose a PHPUnit Version for Fedora
Pick the newest PHPUnit major version your project supports. New projects should start with PHPUnit 13, while older Laravel, Symfony, WordPress plugin, or custom PHP codebases may need a previous major release until their assertions and test doubles are updated.
| Package | Command | PHP Requirement | Upstream Support State |
|---|---|---|---|
phpunit13 | phpunit13 | PHP 8.4+ | Bug fixes through February 2028 |
phpunit12 | phpunit12 | PHP 8.3+ | Bug fixes through February 2027 |
phpunit11 | phpunit11 | PHP 8.2+ | Life Support, bug fixes ended February 2026 |
phpunit10 | phpunit10 | PHP 8.1+ | Life Support, bug fixes ended February 2025 |
phpunit9 | phpunit9 | PHP 7.3+ | Life Support, bug fixes ended February 2024 |
phpunit8 | phpunit8 | PHP 7.2+ | Life Support, bug fixes ended February 2023 |
The upstream PHPUnit supported versions page is the source of truth for PHP requirements and support timelines. Fedora’s phpunit13 package page confirms that the Fedora package provides PHPUnit 13 through the phpunit13 command.
If your project already manages development tools with Composer, keep PHPUnit as a project-local dependency instead of relying only on a system command. The typical Composer form is
composer require --dev phpunit/phpunit:^13, then./vendor/bin/phpunitfrom the project directory. Use the guide to install Composer on Fedora if Composer is not available yet.
Composer can require a PHP version for a project, but it does not switch Fedora’s active php command. If Composer or PHPUnit reports a platform mismatch, check the active runtime with php -r 'echo PHP_MAJOR_VERSION . "." . PHP_MINOR_VERSION . PHP_EOL;' before changing packages.
Update Fedora Before Installing PHPUnit
Refresh Fedora package metadata and apply pending updates before installing the runner:
sudo dnf upgrade --refresh
The --refresh option forces DNF to check current repository metadata instead of reusing an older local cache.
Install PHPUnit with DNF
Install the current PHPUnit package for most new and actively maintained projects:
sudo dnf install phpunit13
For an older project, install the matching major version instead. This example installs PHPUnit 12:
sudo dnf install phpunit12
Use phpunit11, phpunit10, phpunit9, or phpunit8 only when the project’s PHP branch and test suite require that older line.
You can install more than one major version at the same time. Each package keeps its own versioned command, such as phpunit13 or phpunit12, while the generic phpunit symlink points to the newest installed major version.
Verify PHPUnit on Fedora
Check the installed runner version:
phpunit13 --version
Fedora 44 currently returns a PHPUnit 13 banner similar to this. The patch version changes as Fedora publishes updates:
PHPUnit 13.1.8 by Sebastian Bergmann and contributors.
If you installed multiple major versions, verify the generic command target:
phpunit --version
readlink -f /usr/bin/phpunit
With PHPUnit 13 installed as the newest major version, the generic command resolves to:
PHPUnit 13.1.8 by Sebastian Bergmann and contributors. /usr/bin/phpunit13
Run a PHPUnit Test on Fedora
A small local test file is enough to confirm the runner, PHP runtime, and PHPUnit assertions work together. Use a separate directory so the sample files stay out of your real project tree.
Create a Demo Test File
Create a temporary project directory and move into it:
mkdir -p ~/phpunit-demo
cd ~/phpunit-demo
Create ExampleTest.php with this test case:
<?php
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
final class ExampleTest extends TestCase
{
public function testAddition(): void
{
$this->assertSame(2, 1 + 1);
}
public function testStringContains(): void
{
$this->assertStringContainsString('Hello', 'Hello World');
}
}
Run the Demo Test
Run the test file with the installed PHPUnit 13 command. The --do-not-cache-result option keeps this one-file demo from trying to write a result cache outside the sample directory.
phpunit13 --do-not-cache-result ExampleTest.php
A passing run looks like this:
PHPUnit 13.1.8 by Sebastian Bergmann and contributors. Runtime: PHP 8.5.6 .. 2 / 2 (100%) Time: 00:00.006, Memory: 4.00 MB OK (2 tests, 2 assertions)
Use TestDox output when you want readable test names instead of only dots:
phpunit13 --do-not-cache-result --testdox ExampleTest.php
For real applications, run PHPUnit from the project root and keep project configuration in phpunit.xml or phpunit.xml.dist. The official PHPUnit documentation covers bootstrap files, data providers, mocks, coverage, and XML configuration.
Update or Remove PHPUnit on Fedora
Fedora updates PHPUnit through DNF, just like the PHP CLI packages and dependency libraries it installs.
Update PHPUnit on Fedora
Use a normal Fedora upgrade to update PHPUnit and its PHP dependencies together:
sudo dnf upgrade --refresh
For a single installed major version, you can target that package directly:
sudo dnf upgrade --refresh phpunit13
DNF package updates keep the installed major version current. When you need to move a project from an older PHPUnit major to PHPUnit 13, install the new versioned package beside the old one and run the suite with the new command before removing the previous runner.
Remove PHPUnit from Fedora
Remove the PHPUnit package you installed. DNF also proposes removing dependency packages that were installed only for that runner, so review the transaction before confirming on shared development systems.
sudo dnf remove phpunit13
If you installed more than one major version, remove each package you no longer need:
sudo dnf remove phpunit13 phpunit12
Verify the package is gone with RPM’s installed-state check:
rpm -q phpunit13 || true
A removed package reports:
package phpunit13 is not installed
Troubleshoot PHPUnit on Fedora
Fix PHPUnit Command Not Found
If the shell cannot find PHPUnit, it prints this error:
bash: phpunit: command not found
Check whether the versioned package is installed first:
rpm -q phpunit13
If Fedora reports that the package is not installed, install it again:
sudo dnf install phpunit13
If the package is installed but the generic command still fails, use the versioned command directly and confirm both binaries are on your PATH:
command -v phpunit phpunit13
A normal Fedora package install returns paths under /usr/bin.
/usr/bin/phpunit /usr/bin/phpunit13
Fix PHP Version Requirement Errors
A custom PHP branch, Remi module stream, or older development container can make PHPUnit reject the active PHP runtime:
This version of PHPUnit requires PHP >= 8.4. You are using PHP 8.3.x.
Check the PHP branch your shell is using:
php -r 'echo PHP_MAJOR_VERSION . "." . PHP_MINOR_VERSION . PHP_EOL;'
Current Fedora 44 systems return PHP 8.5, while Fedora 43 returns PHP 8.4. If your shell reports an older custom PHP branch, either install the older PHPUnit package that matches that branch or review the guide to install PHP on Fedora before changing system PHP packages.
Fix Result Cache Permission Warnings
When running Fedora’s packaged PHPUnit against a single file, you may see a warning about the result cache even though the tests pass:
PHP Warning: file_put_contents(/usr/bin/.phpunit.result.cache): Failed to open stream: Permission denied
Use --do-not-cache-result for one-off file checks, or configure a writable cache directory in your project-level PHPUnit configuration:
phpunit13 --do-not-cache-result ExampleTest.php
A clean rerun returns the normal passing output without the warning. For full projects, set a writable cache directory in phpunit.xml instead of disabling the cache every time.
Conclusion
PHPUnit is available on Fedora as versioned DNF packages, with phpunit13 covering current PHP 8.4 and 8.5 projects and older commands available for legacy test suites. Keep the system runner updated with Fedora, then use the guide to install Composer on Fedora when a project needs its own pinned PHPUnit dependency.


Formatting tips for your comment
You can use basic HTML to format your comment. Useful tags currently allowed in published comments:
<code>command</code>command<strong>bold</strong><em>italic</em><blockquote>quote</blockquote>