I am running phpunit locally on OSX with 1 test to see if I get a response back from Gearman. I get the following error:
PHP Fatal error: Class 'GearmanClient' not found
Here is the code:
class GearmanTest extends PHPUnit_Framework_TestCase {
public function testGearmanClient() {
$gmc = new GearmanClient();
$gmc->addServer('localhost');
}
}
The strange thing is that if I don't try to run it through phpunit, it works just fine. Call me crazy, but aren't they both simple cli processes? I did notice a difference in the include_path found, but when I force the include path to be the same, there is no effect.
Please help.
If the class GearmanClient
can't be found (as described in your example), then that's because the extension is not installed.
Try running
$ php -i | grep gearman
If the extension were installed, then the above command would output something like
Additional .ini files parsed => /usr/local/etc/php/5.6/conf.d/ext-gearman.ini,
gearman
gearman support => enabled
libgearman version => 1.1.12
e2 => feature/gearman-manager
_SERVER["e2"] => feature/gearman-manager
You can probably find something here on Stackoverflow how to install it on your system.
If you're on OS X, you probably want to use http://brew.sh for installing packages, and here's a great post about installing PHP with Homebrew on OS X:
Once you got PHP installed, for example, PHP5.6, it's as easy as running
$ brew install gearman