Reputation: 156
I'm on macOS sierra.
I installed mongodb using brew and starting it using $ mongod
command.
Also, the mongo shell works fine without any luck!
The problem is when i'm using this code to create a connection:
$mongoClient = new MongoDB\Client();
same for
$mongoClient = new MongoClient();
I'm getting this error:
Fatal error: Uncaught Error: Class ... not found in ...
The fun point is when i'm trying to use mongo driver manager it works!
$manager = new MongoDB\Driver\Manager("mongodb://localhost:27017");
I'm sure that i have extension=mongo.so
in my php.ini file and i checked phpinfo() and that shows Mongodb is loaded, i can'f find a solution for fixing it!
whats the problem?
Upvotes: 2
Views: 3699
Reputation: 5252
You must properly install the MongoDB driver. With phpinfo()
you can check if it is working.
Then install PHP library for MongoDB.
Also you should do not forget that PHP-CLI and PHP-FPM/mod_php have separated configurations (the php.ini files)
Upvotes: 4