PHPackages                             tomzx/job - 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. tomzx/job

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

tomzx/job
=========

Job runner for PHP.

v0.1.0(9y ago)3221MITPHPPHP &gt;=7.0

Since Oct 30Pushed 9y agoCompare

[ Source](https://github.com/tomzx/job)[ Packagist](https://packagist.org/packages/tomzx/job)[ Docs](https://github.com/tomzx/job)[ RSS](/packages/tomzx-job/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

Job
===

[](#job)

[![License](https://camo.githubusercontent.com/98a74f50526924eebd98443625a3d43c6eee419575a607a053c1a0f47a08f8a2/68747470733a2f2f706f7365722e707567782e6f72672f746f6d7a782f6a6f622f6c6963656e73652e737667)](https://packagist.org/packages/tomzx/job)[![Latest Stable Version](https://camo.githubusercontent.com/e72964b8ac430e892951694eee1908bbce8ed9bfa86d30fe4f2461953fff4959/68747470733a2f2f706f7365722e707567782e6f72672f746f6d7a782f6a6f622f762f737461626c652e737667)](https://packagist.org/packages/tomzx/job)[![Latest Unstable Version](https://camo.githubusercontent.com/e0f21f580dc2360d9167a003a502323699b40ba2e7653470eb96a1a8bf4a40ea/68747470733a2f2f706f7365722e707567782e6f72672f746f6d7a782f6a6f622f762f756e737461626c652e737667)](https://packagist.org/packages/tomzx/job)[![Build Status](https://camo.githubusercontent.com/be90b6695f06e9f42d0d4ea43c4cbf1f6aa0416b989eaa7784ed9131776e5480/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f746f6d7a782f6a6f622e737667)](https://travis-ci.org/tomzx/job)[![Code Quality](https://camo.githubusercontent.com/1c24818bc2613d9d4193991e835424e638569e8afed0e0ef419eb2dde58bde57/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f746f6d7a782f6a6f622e737667)](https://scrutinizer-ci.com/g/tomzx/job/code-structure)[![Code Coverage](https://camo.githubusercontent.com/f37c3178a286c852ba871db941eb6deedfa7759f6754d66b5ba0595219800c64/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f746f6d7a782f6a6f622e737667)](https://scrutinizer-ci.com/g/tomzx/job)[![Total Downloads](https://camo.githubusercontent.com/72e42d86c37df22e718d420d71ef565aa8c046830416c799853787bd3a3a587f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746f6d7a782f6a6f622e737667)](https://packagist.org/packages/tomzx/job)

`Job` is a small library which purpose is to handle the creation and execution of jobs that may be executed synchronously or asynchronously.

Getting started
---------------

[](#getting-started)

- In a console, `php composer.phar require tomzx/job`

Example
-------

[](#example)

```
use tomzx\Job\Job;
use tomzx\Job\Throttler;

class SymfonyProcessJob extends Job
{
    /**
     * @var \Symfony\Component\Process\Process
     */
    private $process;

    public function __construct(Process $process)
    {
        $this->process = $process;
    }

    public function handle()
    {
        $this->process->start();
    }

    public function getProcess()
    {
        return $this->process;
    }

    public function isResolved()
    {
        return $this->process->isTerminated();
    }
}

// Create a throttler with a maximum of 5 jobs in parallel
$throttler = new Throttler(5);

// Bind event handlers
$throttler->onJobWaiting(function (SymfonyProcessJob $job) {
    echo 'New job added!' . PHP_EOL;
});

$throttler->onJobRunning(function (SymfonyProcessJob $job) {
    echo 'Job running!' . PHP_EOL;
});

$throttler->onJobCompleted(function (SymfonyProcessJob $job) {
    echo $job->getProcess()->getOutput() . PHP_EOL;
});

// Create a couple of jobs
for ($i = 0; $i < 10; ++$i) {
	// Push the jobs, they will not be started until ->wait is called()
	$throttler->push(new SymfonyProcessJob(new Process('sleep 1 && time')));
	// Push the jobs and start them right away
	//$throttler->pushAndStart(new SymfonyProcessJob(new Process('sleep 1 && time')));
}

// Block until the jobs are completed
$throttler->wait();
```

Async jobs can also be handled in a more "promise-oriented" fashion

```
class TestJob extends Job
{
    private $handled = false;

    public function handle()
    {
        static $i = 0;
        echo ++$i . PHP_EOL;
        sleep(1);
        $this->handled = true;
    }

    public function isResolved()
    {
        return $this->handled;
    }
}

$jobQueue = new JobQueue();

// Create a couple of jobs
for ($i = 0; $i < 10; ++$i) {
	$job = new TestJob();
	$job->handle();
	$jobQueue->push($job);
}

$awaiter = new Awaiter();
// Await completion of all jobs
// jobs = $awaiter->all($jobQueue);
// Await completion of any job
// $job = $awaiter->any($jobQueue);
// Await completion of a given amount of jobs
// $jobs = $awaiter->some($jobQueue, 2);
```

License
-------

[](#license)

The code is licensed under the [MIT license](http://choosealicense.com/licenses/mit/). See [LICENSE](LICENSE).

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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

3531d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/218f6db237e6937c05550d4d6df648f50cd9b26b098fc8c1be3930fe7d5c71e9?d=identicon)[tomzx](/maintainers/tomzx)

---

Top Contributors

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

---

Tags

asyncqueuejob

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tomzx-job/health.svg)

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

###  Alternatives

[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

145810.0k4](/packages/clue-mq-react)[imtigger/laravel-job-status

Laravel Job Status

5352.2M3](/packages/imtigger-laravel-job-status)[jms/job-queue-bundle

Allows to run and schedule Symfony console commands as background jobs.

3452.3M5](/packages/jms-job-queue-bundle)[dereuromark/cakephp-queue

The Queue plugin for CakePHP provides deferred task execution.

308954.9k25](/packages/dereuromark-cakephp-queue)[mpbarlow/laravel-queue-debouncer

A wrapper job for debouncing other queue jobs.

63825.7k1](/packages/mpbarlow-laravel-queue-debouncer)[tarantool/queue

PHP bindings for Tarantool Queue.

65137.6k4](/packages/tarantool-queue)

PHPackages © 2026

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