0

As a Topic title. I work with cron service to execute artisan command every minute. I have a problem when I try to execute command via terminal for debuging. I got error Class 'MongoClient' not found.

So I try to do simple query in laravel Route

$m  = new MongoClient('mongodb://localhost:27017');
$db = $m->rootan;
print_r($db) ;
$result = $db->campaigns->findOne();
print_r($result) ;

I got a result with no error perfectly.

So my question is why I get this error when execute command from terminal. Do this problem is something about Permission?

Sorry for my english.

PS. I use Ubuntu14.04 with Laravel4.2 and MongoDB3

  • Sorry for missing I use this command in command line php artisan command:testScheduled 56a9b3d0d894e2f5058b4567 – Pongpon Thetthotsaporn Jan 28 '16 at 09:58
  • Already answered [here](http://stackoverflow.com/questions/24533938/class-mongoclient-not-found), [here](http://stackoverflow.com/questions/28337754/php-fatal-error-class-mongoclient-not-found) and [here](http://stackoverflow.com/questions/24251810/laravel-4-class-mongoclient-not-found). Check if one of these solves your problem. – Abhinav Gauniyal Jan 28 '16 at 10:42
  • Thx for your help but I did install php mongo driver already. I also can interact with mongodb in my application but I only got the error when i try to run php file from terminal. So I wonder why its happen like this. Any ideas? – Pongpon Thetthotsaporn Jan 28 '16 at 12:19
  • @PongponThetthotsaporn did you get a solution for this? – coder Jan 11 '18 at 10:40

0 Answers0