©
This document uses PHP Chinese website manual Release
[#1] Anonymous [2013-04-24 10:54:48]
For my previous comment:
this line:
<?php
$worker->addFunction(new MyClass($test), 'myMethod');
?>
change to:
<?php
$worker->addFunction($taskName, array(new MyClass(), 'myMethod'));
?>
[#2] spacewalker2002 at ukr dot net [2013-04-23 11:34:39]
You can use this syntax:
<?php
$worker = new GearmanWorker();
$worker->addServer();
$worker->addFunction(new MyClass($test), 'myMethod');
class MyClass
{
public function __construct($test)
{
$this->test = $test;
}
public function myMethod(GearmanJob $job)
{
// you can access to $this->test;
}
}
[#3] jon dot skarpeteig at gmail dot com [2012-08-29 08:26:38]
Unfortunately there's no manager in the pecl extension. If you want to make use of admin features, check out: http://pear.php.net/package/Net_Gearman which implements the administrative protocol in Manager.php as defined in: http://gearman.org/?id=protocol