There is no dearth of examples showing how to use Gearman from PHP out there. A typical one would go like this
**CLIENT**
<?php
$client= new GearmanClient();
$client->addServer();
print $client->do("revit", "AlL THE World's a sTagE");
print "
";
?>
**SERVER**
<?php
$worker= new GearmanWorker();
$worker->addServer();
$worker->addFunction("revit", "rev_it");
while ($worker->work());
function rev_it($job)
{
return strrev($job->workload());
}
?>
I installed Gearmand and the PECL PHP extension on my 64 bit CentOS server, wrote up these scripts, ensured that Gearmand was running and then browsed to the client. The browser waited... .
I had fully expected this since I figured that the Gearman server needs to somehow know that it should execute that particular worker script when it receives an appropriate client request.
I opened another tab and browsed to the worker script and promptly got back a response in the client script tab.
There appears to be a missing link here. When one writes a worker script does it not somehow have to be registered with the Gearman server so the latter knows to use it to service certain clients?
Either I have been Googling for the wrong things or else all those "How to use Gearman in PHP" examples leave out something. Could someone here help?