I lauch a script with crontab every 2min. This script is using a php file using MongoDB. When I lauch the file via the browser, everything works perfect. But when its lauched by cron, it sends this error :
Fatal error: Class 'MongoDB\Driver\Manager' not found in myfile.php on line 19
Can you please help me understand ? Mongo Driver is installed correctly since the scrip works well via my browser..
Thanks.
This is because you have to enable mongodb for php cli separately. To check if it is already enabled, in your command line, try : php -m | grep -i mongo
If no results is output, enable it on cli/php.ini
file. ex: In latest ubuntu versions it is located at /etc/php/[Your_PHP_Version]/cli/php.ini
my php.ini has the mongodb extension as well : extension=mongodb.so I'm using Mamp