will not load with PHP 8.1 on Ubuntu 22.04

Has anyone successfully installed PHP8.1 with the driver in linux?
I am using Ubuntu 22.04, which is running flawlessly.

1… I have installed mongodb, which works as advertised using the mongosh shell.
2… PHP is installed using the recommended installation process.
3… The mongodb driver is installed through pear(PECL)
4… I have verified that is actually in folder /usr/lib/php/20210902
4… I have added to the php.ini file which is located in /etc/php/8.1/apache2/
5… I have added the extension dir /usr/lib/php/20210902, which isn’t supposed to be necessary, but I did it anyway.

Both of the paths above are exactly the same as reported in phpinfo.php

When I verify my installation using php -m, I get the following error

PHP Startup: Unable to load dynamic library ‘’ (tried: /usr/lib/php7/modules/ (/usr/lib/php7/modules/ undefined symbol: ns_parserr), /usr/lib/php7/modules/ (/usr/lib/php7/modules/ cannot open shared object file: No such file or directory))

This is the installation process I have used.
sudo apt install apache2
sudo apt install php


sudo apt install php-dev php-pear
sudo apt -y install php-mongodb

You don’t show yourself installing the MongoDB PHP Extension via sudo pecl install mongodb

I see where I installed it incorrecrly. re-installed with sudo pecl install mongodb. Still will not connect.
I have tried new mongodbClient(‘localhost:27017’)
I have tried new mongodb\driver\manager(‘localhost:27017’)
both throw this err recorder in apache2 error log
Uncaught Error: Class ‘MongoDB\Driver\Manager’ not found is in the folder /usr/lib/php/20210902
I have 2 php.ini /etc/php/8.1/apache2/php.ini – /etc/php/8.1/cli/php.ini and the extension is loaded in both. the one in /cli is the loaded file.
php -m verifies that the extension is loaded and phpinfo verifies that mongodb is loaded

I am at an impass. I can’t think of anything else.

You have to have the vendor stuff at hand, e…g, require_once getenv('DOCUMENT_ROOT') . '/../vendor/autoload.php'; … you’re not loading the MongoDB library on top of the extension.

$ php -a
Interactive shell

php > require_once('vendor/autoload.php');
php > $x = new \MongoDB\Client('mongodb://localhost');
php > var_dump($x);
object(MongoDB\Client)#3 (4) {
  object(MongoDB\Driver\Manager)#2 (2) {
    string(19) "mongodb://localhost"
    array(0) {
  string(19) "mongodb://localhost"
  array(3) {
    string(23) "MongoDB\Model\BSONArray"
    string(26) "MongoDB\Model\BSONDocument"
    string(26) "MongoDB\Model\BSONDocument"
  object(MongoDB\Driver\WriteConcern)#6 (0) {
php >

When you have multiple php.ini files, you can create a PHP info file, and output the current PHP configuration to verify which version is active, and which php.ini file is being used.

It would show up like this, for example:
Loaded Configuration File C:\SOME_PATH\bin\php\php-7.4.30-Win32-vc15-x64\php.ini

When you search for “MongoDB” in the page, there’s a whole section that shows if MongoDB is active, and which version of the driver is loaded (or not).

if you have a file named mongodb.ini in the route /etc/php/8.1/mods-available whit the content “”, you can tried comment this line, this works fine for me in php 8.1 and mongodb extensión 1.14.2.