The code you’ve posted uses the MongoClient class from the legacy driver as you’ve indicated. As I mentioned, there is a new extension (ext-mongodb) along with a new library (mongodb/mongodb on packagist), which is what we support. The legacy extension is no longer supported. Please run the following commands in your project directory one by one and post the complete output so we can figure out what you’re running:

composer show mongodb/mongodb
composer show alcaeus/mongo-php-adapter
php --ri mongo
php --ri mongodb
1 Like