Are you looking for an easy way to install PHPUnit on CentOS 7 / CentOS 8 & Fedora 40/39/38/37/36?. PHPUnit is a unit testing framework for PHP applications. It is an instance of the xUnit architecture for unit testing frameworks and it became popular with JUnit. PHPUnit requires PHP dom and json , pcrereflection and spl extensions.

Add Remi repository

PHPUnit package for CentOS 7/8 will be pulled from Remi repository which is not readily available on either system. Add it manually using the commands shared below.

CentOS 8:

sudo dnf -y install http://rpms.remirepo.net/enterprise/remi-release-8.rpm
sudo dnf -y install dnf-utils
sudo dnf -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

CentOS 7:

sudo yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum -y install epel-release
sudo yum -y install yum-utils

Fedora:

# Fedora 40
sudo dnf -y install http://rpms.remirepo.net/fedora/remi-release-40.rpm
sudo dnf -y install dnf-utils

# Fedora 39
sudo dnf -y install http://rpms.remirepo.net/fedora/remi-release-39.rpm
sudo dnf -y install dnf-utils

# Fedora 38
sudo dnf -y install http://rpms.remirepo.net/fedora/remi-release-38.rpm
sudo dnf -y install dnf-utils

# Fedora 37
sudo dnf -y install http://rpms.remirepo.net/fedora/remi-release-37.rpm
sudo dnf -y install dnf-utils

# Fedora 36
sudo dnf -y install http://rpms.remirepo.net/fedora/remi-release-36.rpm
sudo dnf -y install dnf-utils

# Fedora 35
sudo dnf -y install http://rpms.remirepo.net/fedora/remi-release-35.rpm
sudo dnf -y install dnf-utils

Install PHPUnit on CentOS / Fedora

Let’s install the latest PHPUnit and required extensions.

CentOS 8 / Fedora:

sudo dnf --enablerepo=remi -y install phpunit9

CentOS 7:

sudo yum-config-manager --disable remi-php54
sudo yum-config-manager --enable remi-php74
sudo yum --enablerepo=remi -y install phpunit9

View more information on the installed package.

$ rpm -qi phpunit9
Name        : phpunit9
Version     : 9.5.28
Release     : 1.fc37.remi
Architecture: noarch
Install Date: Tue 24 Jan 2023 08:26:03 PM UTC
Group       : Unspecified
Size        : 1438302
License     : BSD-3-Clause
Signature   : RSA/SHA256, Mon 16 Jan 2023 07:17:15 AM UTC, Key ID 83c0639e1fef0014
Source RPM  : phpunit9-9.5.28-1.fc37.remi.src.rpm
Build Date  : Mon 16 Jan 2023 06:54:14 AM UTC
Build Host  : builder.remirepo.net
Packager    : Remi Collet
...

Visit PHPUnit Documentation page to get started.

More content:

Best CCNP R&S Certification Preparation books

Best Kubernetes Study books

Best Linux Books for Beginners & Experts

LEAVE A REPLY

Please enter your comment!
Please enter your name here