PHPackages                             thcolin/silex-gearman-service - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. thcolin/silex-gearman-service

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

thcolin/silex-gearman-service
=============================

022PHP

Since May 1Pushed 10y ago1 watchersCompare

[ Source](https://github.com/thcolin/silex-gearman-service)[ Packagist](https://packagist.org/packages/thcolin/silex-gearman-service)[ RSS](/packages/thcolin-silex-gearman-service/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Gearman Silex Service
=====================

[](#gearman-silex-service)

PHP library to facilitate the use of Gearman bin.

The library use two majors service **gearman.jobs** to manage jobs, and **gearman.workers** to manage workers.

Installation
------------

[](#installation)

Install with composer :

```
composer require thcolin/silex-gearman-service dev-master

```

Example :
---------

[](#example-)

Assuming a simple architecture :

- `bootstrap.php` who will create, configure and return our Silex `$app`
- `lifecycle.php` who will just make the life cycle of a job and worker
- `console.php` who will be executable and able us to run job in background

```
/*
 * bootstrap.php
 */
use Silex\Application;
use Knp\Provider\ConsoleServiceProvider;
use thcolin\Gearman\GearmanProvider;

require __DIR__.'/vendor/autoload.php';

$app = new Application();

// used to launch job in background
$app -> register(new ConsoleServiceProvider(), [
  'console.name'              => 'GearmanConsole',
  'console.version'           => '1.0.0',
  'console.project_directory' => __DIR__
]);

$app -> register(new GearmanProvider(), [
  'gearman.options' => [
    'server' => '127.0.0.1:4730', // gearman server
    'json' => __DIR__.'/jobs.json', // json file used to save jobs
    'console' => __DIR__.'/console' // console to launch background job
  ]
]);

return $app;
```

```
/*
 * lifecycle.php : JobService & WorkerService usage
 */

use thcolin\Gearman\Job\Job;
use thcolin\Gearman\Job\JobService;

$app = require __DIR__.'/bootstrap.php';

// Fire olds workers
foreach($app['gearman.workers'] -> workers() as $worker){
  $app['gearman.workers'] -> fire($worker);
  echo "Worker  fired.\n";
}

// Hire new  worker
$app['gearman.workers'] -> hire(['thcolin\Gearman\Worker\ReverseWorker']);
echo "Worker  hired.\n\n";

// RUN_NORMAL (will display the job with the result once finished)
$job = new Job('reverse', ['string' => 'Hello World !']);
echo "Running Job ...\n";
$app['gearman.jobs'] -> run($job, JobService::RUN_NORMAL);
$job = $app['gearman.jobs'] -> refresh($job);
echo "Result Job  : ".$job -> getResult()."\n\n";

// RUN_BACKGROUND (check with the "WatchTaskCommand" on the console and the UUID of the job)
$job = new Job('reverse', ['string' => 'Hello World !']);
echo "Running Job  in background\n";
$app['gearman.jobs'] -> run($job, JobService::RUN_BACKGROUND);
```

```
/*
 * console.php : Console example
 */

use Knp\Provider\ConsoleServiceProvider;
use thcolin\Gearman\GearmanProvider;

$app = require __DIR__.'/bootstrap.php';

$console = $app['console'];
$console -> add(new thcolin\Gearman\Command\FireWorkerCommand);
$console -> add(new thcolin\Gearman\Command\HireWorkerCommand);
$console -> add(new thcolin\Gearman\Command\AddJobCommand);
/* Without a console with "RunJobCommand" you will not be able to launch job with JobService::RUN_BACKGROUND */
$console -> add(new thcolin\Gearman\Command\RunJobCommand);
$console -> add(new thcolin\Gearman\Command\WatchJobCommand);
$console -> add(new thcolin\Gearman\Command\DeleteJobCommand);
$console -> run();
```

Todo
----

[](#todo)

- Scaleway worker integration
- Worker abstract class (actually just a `ReverseWorker` to test)

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/9131757?v=4)[Thomas Colin](/maintainers/thcolin)[@thcolin](https://github.com/thcolin)

---

Top Contributors

[![thcolin](https://avatars.githubusercontent.com/u/9131757?v=4)](https://github.com/thcolin "thcolin (9 commits)")

### Embed Badge

![Health badge](/badges/thcolin-silex-gearman-service/health.svg)

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

###  Alternatives

[klaussilveira/simple-shm

SimpleSHM is a simple and small abstraction layer for shared memory manipulation using PHP.

1357.2k1](/packages/klaussilveira-simple-shm)

PHPackages © 2026

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