How To Install php-mongodb on CentOS 7

In this tutorial we learn how to install php-mongodb on CentOS 7. php-mongodb is MongoDB driver library

Introduction

In this tutorial we learn how to install php-mongodb on CentOS 7.

What is php-mongodb

This library provides a high-level abstraction around the lower-level drivers for PHP and HHVM (i.e. the mongodb extension). While the extension provides a limited API for executing commands, queries, and write operations, this library implements an API similar to that of the legacy PHP driver. It contains abstractions for client, database, and collection objects, and provides methods for CRUD operations and common commands (e.g. index and collection management). Autoloader

We can use yum or dnf to install php-mongodb on CentOS 7. In this tutorial we discuss both methods but you only need to choose one of method to install php-mongodb.

Install php-mongodb on CentOS 7 Using yum

Update yum database with yum using the following command.

sudo yum makecache

After updating yum database, We can install php-mongodb using yum by running the following command:

sudo yum -y install php-mongodb

Install php-mongodb on CentOS 7 Using dnf

If you don’t have dnf installed you can install DNF on CentOS 7 first. Update yum database with dnf using the following command.

sudo dnf makecache

After updating yum database, We can install php-mongodb using dnf by running the following command:

sudo dnf -y install php-mongodb

How To Uninstall php-mongodb on CentOS 7

To uninstall only the php-mongodb package we can use the following command:

sudo dnf remove php-mongodb

References

Summary

In this tutorial we learn how to install php-mongodb on CentOS 7 using yum and dnf.