PHPackages                             inhere/gearman - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. inhere/gearman

AbandonedArchivedLibrary[Queues &amp; Workers](/categories/queues)

inhere/gearman
==============

a php gearman workers manager tool library

v1.0.0(8y ago)2163MITPHPPHP &gt;=5.6.0

Since May 21Pushed 8y ago1 watchersCompare

[ Source](https://github.com/inhere/php-gearman-manager)[ Packagist](https://packagist.org/packages/inhere/gearman)[ Docs](http://github.com/inhere/php-gearman-manager)[ RSS](/packages/inhere-gearman/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)DependenciesVersions (3)Used By (0)

gearman manager
===============

[](#gearman-manager)

a php gearman workers manager.

> [中文README](README_zh.md)

Can start and manage multiple gearman worker, you can set the maximum execution time of each worker and the maximum number of job execution, after reaching the set value. Worker will automatically restart the process, prevent the dead

Learning reference the project **[brianlmoon/GearmanManager](https://github.com/brianlmoon/GearmanManager)**, Thank you very much for this project.

add some feature:

- Code is easier to read and understand
- Can support `start` `reload` `restart` `stop` `status` command
- More useful feature

> only support linux system, and require enable `pcntl` `posix`

### basic commands

[](#basic-commands)

- start

```
// start
php bin/manager.php
// run as daemon
php bin/manager.php --daemon
```

- stop

```
php bin/manager.php stop
```

- restart

```
php bin/manager.php restart
```

- more

```
// see help info
php bin/manager.php --help

// print manager config info
php bin/manager.php -D

// jobs status
php bin/manager.php status
php bin/manager.php status --cmd status

// workers status
php bin/manager.php status --cmd workers
```

commands and options
--------------------

[](#commands-and-options)

use `php examples/gwm.php -h`, you can see all commands and options.

```
root@php5-dev:/var/www/phplang/library/gearman-manager# php examples/gwm.php -h
Gearman worker manager(gwm) script tool. Version 0.1.0

USAGE:
  php examples/gwm.php {COMMAND} -c CONFIG [-v LEVEL] [-l LOG_FILE] [-d] [-w] [-p PID_FILE]
  php examples/gwm.php -h
  php examples/gwm.php -D

COMMANDS:
  start             Start gearman worker manager(default)
  stop              Stop running's gearman worker manager
  restart           Restart running's gearman worker manager
  reload            Reload all running workers of the manager
  status            Get gearman worker manager runtime status

SPECIAL OPTIONS:
  start/restart
    -w,--watch         Automatically watch and reload when 'loader_file' has been modify
    -d,--daemon        Daemon, detach and run in the background
       --jobs          Only register the assigned jobs, multi job name separated by commas(',')
       --no-test       Not add test handler, when job name prefix is 'test'.(eg: test_job)

  status
    --cmd COMMAND      Send command when connect to the job server. allow:status,workers.(default:status)
    --watch-status     Watch status command, will auto refresh status.

PUBLIC OPTIONS:
  -c CONFIG          Load a custom worker manager configuration file
  -s HOST[:PORT]     Connect to server HOST and optional PORT, multi server separated by commas(',')

  -n NUMBER          Start NUMBER workers that do all jobs

  -u USERNAME        Run workers as USERNAME
  -g GROUP_NAME      Run workers as user's GROUP NAME

  -l LOG_FILE        Log output to LOG_FILE or use keyword 'syslog' for syslog support
  -p PID_FILE        File to write master process ID out to

  -r NUMBER          Maximum run job iterations per worker
  -x SECONDS         Maximum seconds for a worker to live
  -t SECONDS         Number of seconds gearmand server should wait for a worker to complete work before timing out

  -v [LEVEL]         Increase verbosity level by one. (eg: -v vv | -v vvv)

  -h,--help          Shows this help information
  -V,--version       Display the version of the manager
  -D,--dump [all]    Parse the command line and config file then dump it to the screen and exit.

```

### add handler

[](#add-handler)

you can add job handler use: `function` `Closure` `Class/Object`

> class or object must be is a class implement the `__invoke()` or a class implement the interface `inhere\gearman\jobs\JobInterface`

- file: `job_handlers.php`

```
/**
 * a class implement the '__invoke()'
 */
class TestJob
{
    public function __invoke($workload, \GearmanJob $job)
    {
        echo "from TestJob, call by __invoke";
    }
}

// add job handlers

$mgr->addHandler('reverse_string', function ($string, \GearmanJob $job)
{
    $result = strrev($string);

    echo "Result: $result\n";

    return $result;
});

$mgr->addHandler('test_job', TestJob::class);

// use a class implement the interface `inhere\gearman\jobs\JobInterface`, add some option for the job.
$mgr->addHandler('echo_job', \inhere\gearman\examples\jobs\EchoJob::class, [
    'worker_num' => 2,
    'focus_on' => 1,
]);
```

- extends `inhere\gearman\Job`

```
/**
 * Class EchoJob
 * @package inhere\gearman\jobs
 */
class EchoJob extends Job
{
    /**
     * {@inheritDoc}
     */
    protected function doRun($workload, \GearmanJob $job)
    {
        echo "receive: $workload";
    }
}
```

### start manager

[](#start-manager)

use `php gwm.php -h` see more help information

run: `php gwm.php`

monitor web panel
-----------------

[](#monitor-web-panel)

you can see the server, jobs, workers info by built-in tool.

run：

```
bash server.sh
// OR
php -S 127.0.0.1:5888 -t web
```

open the url

- server,jobs info

[![](web/assets/svr-info.png)](web/assets/svr-info.png)

- see log

[![](web/assets/log-info1.png)](web/assets/log-info1.png)

License
-------

[](#license)

BSD

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3277d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d23e1decaf354e8f36a7ad61128865dc78dd63336c2d023d79aa3ff8ba2a05ff?d=identicon)[inhere](/maintainers/inhere)

---

Top Contributors

[![inhere](https://avatars.githubusercontent.com/u/5302062?v=4)](https://github.com/inhere "inhere (92 commits)")

---

Tags

gearmangearman-managerphp-libraryworker-managementlibrarymanagerworkergearman

### Embed Badge

![Health badge](/badges/inhere-gearman/health.svg)

```
[![Health](https://phpackages.com/badges/inhere-gearman/health.svg)](https://phpackages.com/packages/inhere-gearman)
```

###  Alternatives

[swarrot/swarrot

A simple lib to consume RabbitMQ queues

3654.4M8](/packages/swarrot-swarrot)[dusterio/laravel-aws-worker

Run Laravel (or Lumen) tasks and queue listeners inside of AWS Elastic Beanstalk workers

3105.7M](/packages/dusterio-laravel-aws-worker)[brianlmoon/gearmanmanager

PHP daemon for managing gearman workers

68290.2k1](/packages/brianlmoon-gearmanmanager)[mmoreram/gearman-bundle

Adds gearman support to your and Symfony4, Symfony5 project

237395.2k2](/packages/mmoreram-gearman-bundle)[php-amqplib/thumper

AMQP Tools

276210.8k8](/packages/php-amqplib-thumper)[clue/mq-react

Mini Queue, the lightweight in-memory message queue to concurrently do many (but not too many) things at once, built on top of ReactPHP

144691.7k4](/packages/clue-mq-react)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
