PHPackages                             arefshojaei/job-queue-system - 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. [Database &amp; ORM](/categories/database)
4. /
5. arefshojaei/job-queue-system

ActiveProject[Database &amp; ORM](/categories/database)

arefshojaei/job-queue-system
============================

A Queue &amp; Job System

1.2.2(1mo ago)00MITPHPPHP &gt;=8.2

Since Jun 15Pushed 1mo agoCompare

[ Source](https://github.com/ArefShojaei/Job-queue-system)[ Packagist](https://packagist.org/packages/arefshojaei/job-queue-system)[ RSS](/packages/arefshojaei-job-queue-system/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

[![image](https://private-user-images.githubusercontent.com/134844185/607124003-952b835a-0c61-44cb-acca-f4ce54cd46f5.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3ODQ4NTQ1OTQsIm5iZiI6MTc4NDg1NDI5NCwicGF0aCI6Ii8xMzQ4NDQxODUvNjA3MTI0MDAzLTk1MmI4MzVhLTBjNjEtNDRjYi1hY2NhLWY0Y2U1NGNkNDZmNS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwNzI0JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDcyNFQwMDUxMzRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0yODBlNGEwNDZmNmRjYzk3NmZlM2VmODk3MDZiMWI2OGU4NTEwOTE0MzRkZWU4YTNjNTVmMTljNjlmMzU0NDcyJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZyZXNwb25zZS1jb250ZW50LXR5cGU9aW1hZ2UlMkZwbmcifQ.8oqRnoHBZqC-Lq6uG5rO0G5HrkWhE5wT1VHX08JvIjg)](https://private-user-images.githubusercontent.com/134844185/607124003-952b835a-0c61-44cb-acca-f4ce54cd46f5.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3ODQ4NTQ1OTQsIm5iZiI6MTc4NDg1NDI5NCwicGF0aCI6Ii8xMzQ4NDQxODUvNjA3MTI0MDAzLTk1MmI4MzVhLTBjNjEtNDRjYi1hY2NhLWY0Y2U1NGNkNDZmNS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwNzI0JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDcyNFQwMDUxMzRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0yODBlNGEwNDZmNmRjYzk3NmZlM2VmODk3MDZiMWI2OGU4NTEwOTE0MzRkZWU4YTNjNTVmMTljNjlmMzU0NDcyJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZyZXNwb25zZS1jb250ZW50LXR5cGU9aW1hZ2UlMkZwbmcifQ.8oqRnoHBZqC-Lq6uG5rO0G5HrkWhE5wT1VHX08JvIjg)PHP Job Queue
=============

[](#php-job-queue)

A lightweight and simple Job Queue system built with pure PHP and MySQL.

This project allows you to dispatch, store, and process background jobs through a command-line worker. It is designed for developers who need a simple background task mechanism without using external queue services.

---

Features
--------

[](#features)

- Lightweight and simple architecture
- MySQL-based job storage engine
- Command-line queue worker
- Job dispatching system
- Event listener support
- Job lifecycle and status management
- Exception and failure handling
- Environment configuration using `.env`
- Eloquent Query Builder integration

---

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

[](#requirements)

- PHP 8.2 or higher
- MySQL 8.0 or higher
- Composer

---

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

[](#installation)

### Install via Composer (Recommended)

[](#install-via-composer-recommended)

```
composer create-project arefshojaei/job-queue-system my-app
```

### Clone the Repository

[](#clone-the-repository)

```
git clone https://github.com/ArefShojaei/Job-queue-system.git
```

---

Project Setup
-------------

[](#project-setup)

### 1. Move into the project directory

[](#1-move-into-the-project-directory)

```
cd my-app
```

### 2. Install dependencies

[](#2-install-dependencies)

```
composer install

# Optional
npm install
```

### 3. Environment Configuration

[](#3-environment-configuration)

Rename the `.env.example` file to `.env` and update the environment variables with your actual project configuration.

```
DB_DRIVER=mysql
DB_HOST=localhost
DB_PORT=3306
DB_USERNAME=
DB_PASSWORD=
DB_REPOSITORY=
```

---

### 4. Database Setup

[](#4-database-setup)

```
# Create 'jobs' & 'failed_jobs' tables
php cli db:init jobs

# Clean (Truncate) 'jobs' & 'failed_jobs' tables
php cli db:clean jobs

# Drop 'jobs' & 'failed_jobs' tables
php cli db:drop jobs
```

---

Running the Queue Worker
========================

[](#running-the-queue-worker)

The worker continuously watches the jobs table and processes available jobs.

```
# {name} => 'jobs' OR 'failed_jobs'
php cli queue:work --table={name}
```

---

Available Commands
------------------

[](#available-commands)

### List all jobs

[](#list-all-jobs)

```
php cli job:list
```

### Dispatch a test job

[](#dispatch-a-test-job)

```
php cli job:test sample
```

### Remove all jobs

[](#remove-all-jobs)

```
php cli db:clean jobs
```

### Remove tables

[](#remove-tables)

```
php cli db:drop jobs
```

---

Creating a Custom Job
=====================

[](#creating-a-custom-job)

Every job must implement the `Job` interface:

```
interface Job
{
    public function handle(): void;
}
```

Example:

```
class SendEmailJob implements Job
{
    public function handle(): void
    {
        // Your background logic goes here
    }
}
```

---

Understanding How Jobs Work
===========================

[](#understanding-how-jobs-work)

This project includes example jobs inside the `app/Jobs` directory. These jobs exist only as examples to help you understand the workflow and architecture of the queue system.

You can use this queue system in two different ways:

### 1. Local Jobs (Same Project)

[](#1-local-jobs-same-project)

You can create your jobs directly inside the `app/Jobs` directory and let the queue worker process them.

This is the simplest approach and is recommended for learning and small applications.

---

### 2. External PHP Applications as Background Tasks

[](#2-external-php-applications-as-background-tasks)

You may also use this project as a standalone background task processor for another PHP application.

In this architecture, your main application and this queue system run as independent applications, similar to separating services in a microservice architecture. However, this project itself is not a separate service or a message broker.

The external application must be written in PHP and must create jobs that follow the same contract:

```
interface Job
{
    public function handle(): void;
}
```

The job object is then serialized and stored inside the queue database, where the worker application can retrieve and execute it.

Because both applications need to understand the same job classes, it is strongly recommended to share the same Composer dependencies, especially the job classes and their namespaces, between the producer application and this queue worker.

A common approach is to extract shared jobs and interfaces into a separate Composer package and install it in both projects. This guarantees compatibility and prevents serialization or class-loading issues.

---

Important Notes
---------------

[](#important-notes)

- This is not a replacement for distributed queue systems like RabbitMQ or Kafka.
- Jobs are PHP objects, so the producer and consumer must understand the same PHP classes.
- Both applications should maintain compatible Composer dependencies.
- The queue worker must always be running to process pending jobs.

---

Done.

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance92

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

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

Every ~2 days

Total

2

Last Release

41d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

clidatabasedispatchereventevent-emitterjoblistenmysqlphpqueueworkerconsolequeuejobevent-emitterworker

### Embed Badge

![Health badge](/badges/arefshojaei-job-queue-system/health.svg)

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

###  Alternatives

[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M134](/packages/roots-acorn)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45444.2k1](/packages/pressbooks-pressbooks)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)[anorgan/qutee

Simple queue manager and task processor for PHP

711.9k1](/packages/anorgan-qutee)

PHPackages © 2026

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