4
votes

I've been wrestling with the MongoDB PHP Driver install for most of this afternoon.

I'm using PHP version 5.5, and I've installed the MongoDB PHP Driver using brew install php55-mongo (although I tried other methods before). The problem is, whenever I try to use MongoClient() I get the error:

Class 'MongoClient' not found

The module "mongo" is listed when I run php -m, but I also get the following warnings:

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/Cellar/php55/5.5.34/lib/php/extensions/no-debug-non-zts-20121212/mongo.so' - dlopen(/usr/local/Cellar/php55/5.5.34/lib/php/extensions/no-debug-non-zts-20121212/mongo.so, 9): image not found in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library '/usr/local/Cellar/php55/5.5.34/lib/php/extensions/no-debug-non-zts-20121212/mongo.so' - dlopen(/usr/local/Cellar/php55/5.5.34/lib/php/extensions/no-debug-non-zts-20121212/mongo.so, 9): image not found in Unknown on line 0

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/opt/php55-mongodb/mongodb.so' - dlopen(/usr/local/opt/php55-mongodb/mongodb.so, 9): image not found in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library '/usr/local/opt/php55-mongodb/mongodb.so' - dlopen(/usr/local/opt/php55-mongodb/mongodb.so, 9): image not found in Unknown on line 0

The module isn't listed when I use phpinfo() or get_loaded_extensions().

Any ideas?

1

1 Answers

0
votes

Check which php mongo driver you have installed. It seems like you have installed new php mongo driver and for that you need to add mongodb.so extension instead of mongo.so also you

As reffered in PHP manual

The MongoClient class

(PECL mongo >=1.3.0) Warning

This extension that defines this class is deprecated. Instead, the MongoDB extension should be used. Alternatives to this class include:

MongoDB\Driver\Manager