A PHP interface for Gearman
PHP
#30 Compare This branch is 138 commits ahead, 55 commits behind lenn0x:master.
Latest commit ffc8049 Feb 3, 2017 @brianlmoon updating the README
Permalink
Failed to load latest commit information.
Net/Gearman remove code only needed for logging Feb 3, 2017
examples Removed the stdClass declaration in method declaration. This insures … Sep 2, 2010
tests * check handle and server on a task (this test still fails) Sep 4, 2010
.gitignore * ignore log from pear run-tests foo.phpt Sep 4, 2010
README.md updating the README Feb 3, 2017
build.xml
composer.json Bugfix include-path in composer.json Jun 26, 2014
package.xml Update package.xml May 8, 2015

README.md

Net Gearman

About

Net_Gearman is a package for interfacing with Gearman. Gearman is a system to farm out work to other machines, dispatching function calls to machines that are better suited to do work, to do work in parallel, to load balance lots of function calls, or to call functions between languages.

Installation

$ composer require brianlmoon/net_gearman

Examples

Client

$client = new Net_Gearman_Client("localhost");
$set = new Net_Gearman_Set();
$task = new Net_Gearman_Task("Reverse_String", "foobar");
$task->attachCallback(
    function($func, $handle, $result){
        print_r($result)
    }
);
$set->addTask($task);
$client->runSet($set, $timeout);

Job

class Reverse_String extends Net_Gearman_Job_Common {

    public function run($workload) {
        $result = strrev($workload);
        return $result;
    }
}

Worker

For easiest use, use GearmanManager for running workers. See: https://github.com/brianlmoon/GearmanManager

$worker = new Net_Gearman_Worker('localhost');
$worker->addAbility('Reverse_String');
$worker->beginWork();