Mac OS X MongoDB和MONGO PHP驱动程序

i try to install MongoDB and Mongo PHP Driver for 5.6.x for MAMP PRO , but i finishing installation (also i add extension on php.ini) but still doesn't work. Any one help me ?

it would be useful if you could give more information about versions (MAMPP version, MongoDB server version, Mongo driver version...).

However the most common problem with Mongo and php is that there are two different drivers, both can be installed through PECL.

  • mongo-php : Legacy driver, not recommended anymore.

    sudo pecl install mongo

    Add to php.ini -> extension=mongo.so

  • mongodb-php : New driver, recommended.

    sudo pecl install mongodb

    Add to php.ini -> extension=mongodb.so

While mongo-driver works with PHP versions < 7.0 mongodb driver works with PHP versions > 5.5. But some libraries are still using old mongo driver (i.e.doctrine) and could need an adapter if you want to work with the new driver.

Old driver repo: https://github.com/mongodb/mongo-php-driver-legacy

New driver repo: https://github.com/mongodb/mongo-php-library

To be sure which driver is working in your system, you can perform this easy test. Create two PHP scripts with the following initialization:

If this works then you have old driver installed $connection = new MongoClient({here your conn data})

If this works then you have the new driver installed $connection = new MongoDB\Driver\Manager({here your conn data})

Hope this will be useful for any user with the same problem on any platform. (Please note the extension for windows user will be .dll instead of .so)