Requirements ¶
Tested under Yii 1.1.6. Require PHP Gearman extension installed.
Usage ¶
Extract the files into the extension directory and change the config like bellow:
'components' => array(
'gearman' => array(
'class' => 'ext.Gearman',
'servers' => array(
array('host' => '127.0.0.1', 'port' => 4731),
),
),
)
Simple example:
// Client example
Yii::app()->gearman->client()->doBackground("reverse", "Hello world!");
// Worker example
function reverse($job)
{
return strrev($job->workload());
}
Yii::app()->gearman->worker()->addFunction("reverse", array($this, 'reverse'));
while($worker->work()) { echo "Done!"; }
Excellent!
Glad to see someone already put together a Gearman ext for Yii. Installing it today :-)
A bit too limited
This extension is really just a wrapper of the Gearman client/worker classes.
For someone looking for a complete solution, this appears to be a good choice: https://github.com/mitallast/yii-gearman
Nice!
Thanks to this extension I have learned about Gearman project and it seems quite interesting!
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.