How to update MongoDB PHP extension

Viewed 1093

I installed mongodb driver on my Ubuntu 18.04 and php 7.4.10 using the command

sudo pecl install mongodb

Also added extension=mongodb.so to my php.ini. Then, I typed the following command because I need mongodb to run a project.

composer require mongodb/mongodb

And the following error was the output of this command:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - mongodb/mongodb 1.7.0 requires ext-mongodb ^1.8 -> the requested PHP extension mongodb has the wrong version (1.7.4) installed.
    - mongodb/mongodb 1.7.0 requires ext-mongodb ^1.8 -> the requested PHP extension mongodb has the wrong version (1.7.4) installed.
    - mongodb/mongodb 1.7.0 requires ext-mongodb ^1.8 -> the requested PHP extension mongodb has the wrong version (1.7.4) installed.
    - Installation request for mongodb/mongodb ^1.7 -> satisfiable by mongodb/mongodb[1.7.0].

It is obviously a compatibility issue. My MongoDB extension is version 1.7.4, and the composer needs to be ^ 1.8.

sudo php --ri mongodb | grep version

MongoDB extension version => 1.7.4
libbson bundled version => 1.16.2
libmongoc bundled version => 1.16.2
libmongocrypt bundled version => 1.0.3

pecl search mongo

Matched packages, channel pecl.php.net:
=======================================
Package Stable/(Latest) Local
mongo   1.6.16 (stable)       MongoDB database driver
mongodb 1.8.0 (stable)  1.8.0 MongoDB driver for PHP

Does anyone know how to update my MongoDB extension? I can't find this information anywhere.

0 Answers
Related