\Error 'MongoDB\\Driver\\Manager' not found when migrating from PHP 7.4 to 8.1

Experiencing Error ‘MongoDB\Driver\Manager’ not found when migrating from PHP 7.4 to 8.1 using docker on Debian 11 in Azure, Kindly assist with resolution or tips to resolve this please.

I perform the below with no resolution:

Make sure you has installed php mongodb
sudo apt install php8.1-mongodb

To do this in Ubuntu, you’ll need the php-pear plugin and php-dev

sudo apt install php-dev php-pear

then you can run:
sudo pecl install mongodb

then add “extension=mongodb.so” to php.ini
then restart your php service

service php8.1-fpm restart

Or

service php-fpm restart

https://www.php.net/manual/en/mongodb.installation.pecl.php#125027

Below was the outcome:

Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
Package php-pear is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

Package php-dev is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package ‘php-dev’ has no installation candidate
E: Package ‘php-pear’ has no installation candidate

Hello @Daniel_Njoku and welcome to the MongoDB developer community!

Each version of PHP require a different .so PHP extension file. If you have the pecl command you can install the extension by running pecl install mongodb

If your webserver is up and running, I suggest using phpinfo() to check

  • which PHP version is active
  • which .ini file is active
  • whether the mongodb extension is active, and which version

We have a great startup article for reference

phpinfo() reference
https://www.php.net/manual/en/function.phpinfo.php

1 Like