For test purposes I have gearman running on localhost. So I run the gearman worker.php file from php command line. When I test this in normal apache mode, mongoDB works just fine, but when it runs from the gearman worker file I get the error “fatal error: class ‘Mongo’ not found”. Now the Mongo class comes from pecl and the mongo.so extension in php.ini. SO yeah, trying to figure out why a php file run from CLI is different. Does it use a separate php.ini file?
Share
You can check which .ini files are being loaded by the CLI version by doing
php --ini. If your PHP was provided by a distro, it’s very possible for it to have two seperate .ini sets, one for web-based and one for CLI. You can get the equivalent info fromphpinfo()when it’s running online as well.To force it to load a particular .ini, you can use
php -c /path/to/file.ini.