(Last Updated On: August 20, 2019)

Are you looking for an easy way to install PHPUnit on CentOS 7 / CentOS 8 / Fedora 30/29?. 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.

Step 1: 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 30
sudo dnf -y install http://rpms.remirepo.net/fedora/remi-release-30.rpm
sudo dnf -y install dnf-utils

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

Step 2: Install PHPUnit on CentOS 7 / CentOS 8 / Fedora 30/29

Let’s install the latest PHPUnit and required extensions.

CentOS 8 / Fedora:

sudo dnf module install php:7.2
sudo dnf --enablerepo=remi -y install phpunit8

CentOS 7:

sudo yum-config-manager --disable remi-php54
sudo yum-config-manager --enable remi-php72
sudo yum --enablerepo=remi -y install phpunit8

View more information on the installed package.

$ rpm -qi phpunit8
Name        : phpunit8
Version     : 8.3.4
Release     : 1.el7.remi
Architecture: noarch
Install Date: Fri 16 Aug 2019 11:39:27 PM CEST
Group       : Unspecified
Size        : 1090013
License     : BSD
Signature   : DSA/SHA1, Mon 12 Aug 2019 04:49:32 AM CEST, Key ID 004e6f4700f97f56
Source RPM  : phpunit8-8.3.4-1.el7.remi.src.rpm
Build Date  : Mon 12 Aug 2019 04:43:27 AM CEST
Build Host  : builder.remirepo.net
Relocations : (not relocatable)
Packager    : https://blog.remirepo.net/
Vendor      : Remi Collet
URL         : https://github.com/sebastianbergmann/phpunit
Bug URL     : https://forum.remirepo.net/
Summary     : The PHP Unit Testing framework version 8
Description :
PHPUnit is a programmer-oriented testing framework for PHP.
It is an instance of the xUnit architecture for unit testing frameworks.

This package provides the version 8 of PHPUnit,
available using the phpunit8 command.

Documentation: https://phpunit.readthedocs.io/

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