How to Install PHPUnit 10 on Fedora 39, 38 Linux

PHPUnit 10 stands as a crucial tool for PHP developers, providing a robust framework to write and run tests on PHP code. This ensures the functionality of the code and helps in identifying potential issues before any public release. For Fedora Linux users, installing PHPUnit 10 is a straightforward process, and this guide will walk you through each step, ensuring you have access to the latest features and improvements.

Key Features of PHPUnit 10:

  • Assertion Methods: PHPUnit 10 offers a variety of assertion methods, enabling developers to comprehensively test their code’s behavior.
  • Data-Driven Testing: The framework supports testing with multiple data sets, ensuring code functionality across various scenarios.
  • Functional Testing: Developers can test interactions between different code segments, validating the overall application performance.
  • Support for Test-Driven Development (TDD): PHPUnit 10 embraces TDD, encouraging developers to write tests prior to the actual code, fostering better software design.
  • Detailed Test Reporting: The framework generates extensive test reports, providing developers with insights into code behavior and performance.

Important Considerations:

  • PHP Version Requirement: PHPUnit 10 necessitates PHP ≥ 8.1. It’s designed to coexist with previous PHPUnit versions (5 through 9), allowing for a smooth transition and compatibility with existing projects.

PHPUnit 10 is an indispensable tool for PHP developers aiming for code excellence. This guide will demonstrate how to install PHPUnit 10 on Fedora Linux, utilizing the command line terminal and the Remi PHP repository to access the latest version. Now, let’s begin.

Install PHPUnit 10 on Fedora

Step 1: Update Fedora Before PHPUnit 10 Installation

Before installing PHPUnit, it’s important to ensure that your Fedora system is fully up-to-date with the latest packages. You can do this by running the following command in your terminal.

sudo dnf upgrade --refresh

This will check your system for available upgrades and prompt you to proceed with the upgrades if desired. By keeping your system up-to-date, you can ensure a smooth and successful installation of PHPUnit.

Step 2: Import Remi RPM for PHPUnit 10 on Fedora

By default, Fedora’s repositories provide access to an older version of PHPUnit. Although Fedora is an upstream release, it is not a rolling release Linux distribution, so it may not always have the latest versions of PHPUnit and PHP. To install the latest version of PHPUnit, it is recommended to import the Remi PHP RPM. This will provide access to the most up-to-date PHPUnit version, ensuring you have access to the latest features and bug fixes.

To install the Remi RPM for PHP, you must use one of the following commands matching your Fedora distribution version:

sudo dnf install -y
sudo dnf install -y
sudo dnf install -y

Remember, you must use the correct command that matches your Fedora distribution version.

Now, if you prefer to work with a specific version of PHP, list the available versions from Remi Repository.

sudo dnf module list php

Then enable the version you want to work with; for example, work with PHP 8.2

sudo dnf module enable php:remi-8.2

Please remember that for PHP 10, a minimum requirement of PHP 8.1 is necessary.

sudo dnf module enable php:remi-8.1

The above is just an example of the minimal version of PHP mobile to enable, you can use anything 8.1 onwards.

Step 3: Install PHPUnit via DNF Command on Fedora

Once you have met the prerequisites, you can install PHPUnit 10 on Fedora. The easiest way to install PHPUnit is to use the package manager, DNF. To install PHPUnit, run the following command.

sudo dnf --enablerepo=remi install phpunit10
example of terminal output of installing phpunit on fedora linux.

Alternatively, if you have specific requirements or limitations, you can also install older PHPUnit versions, such as PHPUnit 9 or PHPUnit 8. This can be done by specifying the desired version when installing PHPUnit using the dnf command for example:

sudo dnf --enablerepo=remi install phpunit9


sudo dnf --enablerepo=remi install phpunit8

Alternatively, run the complete installation of all available versions.

sudo dnf --enablerepo=remi install php-phpunit-PHPUnit

By installing an older version of PHPUnit, you can ensure compatibility with existing projects or applications that may not support the latest version.

PHPUnit 10 Test Case with on Fedora

Create Test Case

To get started with PHPUnit, you need to create a test case. A test case is a code that tests a specific aspect of your project. Create a new file with the “.php” extension in your project directory to create a test case.

In this file, include the following code.


use PHPUnit\Framework\TestCase;

final class ExampleTest extends TestCase
    public function testAddition(): void
        $this->assertSame(2, 1 + 1);

This code creates a simple test case that tests adding two numbers.

Running Tests

To run the tests in your test case, use the following command.

phpunit path/to/testcase.php


Installing PHPUnit on Fedora Linux is a straightforward process. With the step-by-step guide in this article, you should have PHPUnit up and running on your Fedora system in no time. PHPUnit is an essential tool for PHP developers, and with it installed, you’ll be able to automate your testing process and ensure the quality of your code.

Leave a Comment