Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A PHP interface for Danga's Gearman
branch: master

This branch is 127 commits ahead, 55 commits behind lenn0x:master

Merge pull request #24 from ddebin/master

Bugfix include-path in composer.json
latest commit 9052dedb88
Brian Moon authored



Net_Gearman is a PEAR package for interfacing with Danga's 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.


   1. Install PEAR if it is not already installed on your system.
   2. Use git to pull this repo to your servers. Be sure where you install it is in the autoload or include path before the rest of PEAR.



require_once 'Net/Gearman/Client.php';

$client = new Net_Gearman_Client('localhost:7003');
    'userid' => 5555,
    'action' => 'new-comment'




class Net_Gearman_Job_someBackgroundJob extends Net_Gearman_Job_Common
    public function run($args)
        if (!isset($args['userid']) || !isset($args['action'])) {
            // Throw a Net_Gearman_Job_Exception to report back to the server that the job failed.
            throw new Net_Gearman_Job_Exception('Invalid/Missing arguments');

        // Insert a record or something based on the $args

        return array(); // Results are returned to Gearman, except for
                        // background jobs like this one.



For easiest use, use GearmanManager for running workers. See:


require_once 'Net/Gearman/Worker.php';

$worker = new Net_Gearman_Worker('localhost:7003');

Something went wrong with that request. Please try again.