Installing the PHP 7 MongoDB Client/Driver?

The Mongo extension for PHP Version 5.99.99 or older has been superseded:

https://pecl.php.net/package/mongo

Use the newer one for PHP Version 7.99.99 or older instead:

https://pecl.php.net/package/mongodb

You can install a PECL/PEAR extension automatically:

pecl install mongodb

or manually.

The classes have been changed too:

new \MongoClient(); // legacy class!

see http://php.net/manual/en/book.mongo.php

new \MongoDB\Driver\Manager(); // new classes! 

see http://php.net/manual/en/set.mongodb.php

Additional information regarding compatibility can be found here:

https://docs.mongodb.org/ecosystem/drivers/php/#compatibility

Leave a Comment