PHPackages                             jfloff/djjob-zf2 - 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. [Framework](/categories/framework)
4. /
5. jfloff/djjob-zf2

AbandonedArchivedLibrary[Framework](/categories/framework)

jfloff/djjob-zf2
================

DJJob for zend 2

1.0.3(13y ago)067Apache-2.0PHPPHP &gt;=5.3

Since Feb 6Pushed 13y ago1 watchersCompare

[ Source](https://github.com/jfloff/djjob-zf2)[ Packagist](https://packagist.org/packages/jfloff/djjob-zf2)[ Docs](https://github.com/jfloff/djjob-zf2)[ RSS](/packages/jfloff-djjob-zf2/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (5)Used By (0)

DJJob
=====

[](#djjob)

DJJob allows PHP web applications to process long-running tasks asynchronously. It is a PHP port of [delayed\_job](http://github.com/tobi/delayed_job) (developed at Shopify), which has been used in production at SeatGeek since April 2010.

Like delayed\_job, DJJob uses a `jobs` table for persisting and tracking pending, in-progress, and failed jobs.

Requirements
------------

[](#requirements)

- PHP5
- PDO (Ships with PHP &gt;= 5.1)
- (Optional) PCNTL library

Setup
-----

[](#setup)

```
mysql db < jobs.sql
```

The `jobs` table structure looks like:

```
CREATE TABLE `jobs` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
`handler` TEXT NOT NULL,
`queue` VARCHAR(255) NOT NULL DEFAULT 'default',
`attempts` INT UNSIGNED NOT NULL DEFAULT 0,
`run_at` DATETIME NULL,
`locked_at` DATETIME NULL,
`locked_by` VARCHAR(255) NULL,
`failed_at` DATETIME NULL,
`error` TEXT NULL,
`created_at` DATETIME NOT NULL
) ENGINE = INNODB;
```

Tell DJJob how to connect to your database:

```
DJJob::configure("mysql:host=127.0.0.1;dbname=djjob_test;port=3306", array('mysql_user' => "root", 'mysql_pass' => "topsecret"));
```

If you’re using mysql, you’ll need to pass the database credentials separately. Otherwise, you can provide those in the connection string, see  for an explanation.

Usage
-----

[](#usage)

Jobs are PHP objects that respond to a method `perform`. Jobs are serialized and stored in the database.

```
class HelloWorldJob {
    public function __construct($name) {
        $this->name = $name;
    }
    public function perform() {
        echo "Hello {$this->name}!\n";
    }
}
```

```
DJJob::enqueue(new HelloWorldJob("delayed_job"));
```

Unlike delayed\_job, DJJob does not have the concept of task priority (not yet at least). Instead, it supports multiple queues. By default, jobs are placed on the “default” queue. You can specifiy an alternative queue like:

```
DJJob::enqueue(new SignupEmailJob("dev@seatgeek.com"), "email");
```

At SeatGeek, we run an email-specific queue. Emails have a `sendLater` method which places a job on the `email` queue. Here’s a simplified version of our base `Email` class:

```
class Email {
    public function __construct($recipient) {
        $this->recipient = $recipient;
    }
    public function send() {
        ...do some expensive work to build the email: geolocation, etc..
        ...use mail api to send this email
    }
    public function perform() {
        $this->send();
    }
    public function sendLater() {
        DJJob::enqueue($this, "email");
    }
}
```

Because `Email` has a `perform` method, all instances of the email class are also jobs.

Running the jobs
----------------

[](#running-the-jobs)

Running a worker is as simple as:

```
$worker = new DJWorker($options);
$worker->start();
```

Initializing your environment, connecting to the database, etc. is up to you. We use symfony’s task system to run workers, here’s an example of our jobs:worker task:

```
class jobsWorkerTask extends sfPropelBaseTask {
  protected function configure() {
    $this->namespace        = 'jobs';
    $this->name             = 'worker';
    $this->briefDescription = '';
    $this->detailedDescription = addOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'propel');
    $this->addOption('queue', null, sfCommandOption::PARAMETER_REQUIRED, 'The queue to pull jobs from', 'default');
    $this->addOption('count', null, sfCommandOption::PARAMETER_REQUIRED, 'The number of jobs to run before exiting (0 for unlimited)', 0);
    $this->addOption('sleep', null, sfCommandOption::PARAMETER_REQUIRED, 'Seconds to sleep after finding no new jobs', 5);
}
```

```
  protected function execute($arguments = array(), $options = array()) {
    // Database initialization
    $databaseManager = new sfDatabaseManager($this->configuration);
    $connection = Propel::getConnection($options['connection'] ? $options['connection'] : '');
```

```
    $worker = new DJWorker($options);
    $worker->start();
  }
}
```

The worker will exit if the database has any connectivity problems. We use [god](http://god.rubyforge.org/) to manage our workers, including restarting them when they exit for any reason.

### Changes

[](#changes)

- Change DJJob::configure to take an options array
- Eliminated Propel dependency by switching to PDO

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

Established project with proven stability

 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

Every ~0 days

Total

4

Last Release

4896d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1867656?v=4)[João Ferreira Loff](/maintainers/jfloff)[@jfloff](https://github.com/jfloff)

---

Top Contributors

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

---

Tags

zf2zend framework 2djjob

### Embed Badge

![Health badge](/badges/jfloff-djjob-zf2/health.svg)

```
[![Health](https://phpackages.com/badges/jfloff-djjob-zf2/health.svg)](https://phpackages.com/packages/jfloff-djjob-zf2)
```

PHPackages © 2026

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