PHPackages                             onlyphp/simple-queue - 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. onlyphp/simple-queue

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

onlyphp/simple-queue
====================

A powerful and flexible job processing system for PHP applications, supporting both CodeIgniter 3 and Laravel frameworks. This package allows you to easily dispatch jobs with various types of processing, including closures, static class methods, object methods, global functions, and invokable classes.

1.0.1(1y ago)06MITPHPPHP &gt;=8.0

Since Jan 1Pushed 1y ago1 watchersCompare

[ Source](https://github.com/faizzul95/SimpleQueue)[ Packagist](https://packagist.org/packages/onlyphp/simple-queue)[ RSS](/packages/onlyphp-simple-queue/feed)WikiDiscussions main Synced 1mo ago

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

PHP Simple Queue
================

[](#php-simple-queue)

A framework-agnostic queue system for PHP that seamlessly integrates with multiple database systems and frameworks. This package offers Laravel-inspired queue functionality without the need for cron jobs, enabling you to effortlessly dispatch jobs with various processing types, including closures, static class methods, object methods, global functions, and invokable classes. This package supports databases such as PDO, MySQL, MSSQL, Oracle and is compatible with CodeIgniter 3, CodeIgniter 4, and Laravel framework.

⚠️ Warning
----------

[](#️-warning)

**DO NOT USE THIS PACKAGE**.

This package is under active development and may contain critical bugs. It is primarily intended for personal use and testing within my own projects.

This version has not undergone rigorous testing and may be unstable or unreliable.

🛠️ Primary Focus (Testing &amp; Development):

- CodeIgniter 3

⏭️ Supported (Experimental):

- PDO
- MySQL
- MSSQL
- Oracle
- CodeIgniter 4
- Laravel

✨ Features
----------

[](#-features)

- 🚀 No cron jobs required - automatic worker process management
- 🔄 Automatic table creation and management
- 💪 Multiple database support (PDO, MySQL, MSSQL, Oracle, CodeIgniter 3/4, Laravel)
- ⚡ Priority queues (urgent, high, normal, low)
- 🔁 Automatic retry mechanism with customizable attempts
- ⏱️ Job timeout handling
- 📊 Job status monitoring
- 🔍 Failed job handling

📝 Requirements
--------------

[](#-requirements)

- PHP &gt;= 8.0

🔧 Installation
--------------

[](#-installation)

Install via Composer:

```
composer require onlyphp/simple-queue
```

🚀 Basic Usage
-------------

[](#-basic-usage)

### Initialize with Different Databases

[](#initialize-with-different-databases)

```
use OnlyPHP\SimpleQueue\JobProcessor;

// PDO MySQL
$pdo = new PDO('mysql:host=localhost;dbname=your_database', 'username', 'password');
$queue = new JobProcessor($pdo);

// PDO MSSQL
$pdoMssql = new PDO('sqlsrv:Server=localhost;Database=your_database', 'username', 'password');
$queueMssql = new JobProcessor($pdoMssql);

// PDO Oracle
$pdoOracle = new PDO('oci:dbname=your_database', 'username', 'password');
$queueOracle = new JobProcessor($pdoOracle);

// CodeIgniter 3
$queue = new JobProcessor($this->db);

// CodeIgniter 4
$db = \Config\Database::connect();
$queue = new JobProcessor($db);

// Laravel
$queue = new JobProcessor(DB::connection());
```

🖥️ Priority Levels
------------------

[](#️-priority-levels)

- `urgent`: Highest priority
- `high`: High priority
- `normal`: Default priority
- `low`: Low priority

🎯 Examples
----------

[](#-examples)

### Simple Jobs

[](#simple-jobs)

```
// Dispatch a closure
$queue->job(function() {
    echo "Processing job...";
})->dispatch();

// Dispatch a function
$queue->job('process_data', ['param1', 'param2'])->setIncludePathFile('/path/to/file.php')->dispatch();

// Dispatch a class method
$queue->job([new YourClass(), 'methodName'], $params)->dispatch();

// Execute job immediately without queueing (foreground processed) using closure/callable
$result = $queue->job($callable)->dispatchNow();
```

### Advanced Jobs

[](#advanced-jobs)

### 1. Email Processing Queue

[](#1-email-processing-queue)

```
class EmailService {
    public function sendBulkEmails(array $recipients, string $template) {
        foreach ($recipients as $recipient) {
            // Process each email
        }
    }
}

// Queue the email job
$emailService = new EmailService();
$recipients = ['user1@example.com', 'user2@example.com'];

$queue->job([$emailService, 'sendBulkEmails'], $recipients)
    ->setName('bulk-email-campaign')
    ->setPriority('high')
    ->setMaxRetries(3)
    ->setRetryDelay(60)
    ->dispatch();
```

### 2. File Processing Queue

[](#2-file-processing-queue)

```
class FileProcessor {
    public function processLargeFile(string $filePath) {
        // Process large file
    }
}

// Queue file processing
$processor = new FileProcessor();
$queue->job([$processor, 'processLargeFile'], $filePath)
    ->setName('large-file-processing')
    ->setTimeout(3600) // 1 hour timeout
    ->dispatch();
```

### 3. Order Processing System

[](#3-order-processing-system)

```
class OrderProcessor {
    public function processOrder(int $orderId, array $items) {
        // Process order logic
    }
}

// Queue order processing
$processor = new OrderProcessor();
$order = [
    'id' => 1234,
    'items' => ['item1', 'item2']
];

$queue->job([$processor, 'processOrder'], $order)
    ->setName("process-order-{$order['id']}")
    ->setPriority('urgent')
    ->setMaxRetries(5)
    ->setRetryDelay(30)
    ->dispatch();
```

### 4. Data Export Jobs

[](#4-data-export-jobs)

```
class DataExporter {
    public function exportToCSV(string $query, string $filename) {
        // Export logic
    }
}

// Queue export job
$exporter = new DataExporter();
$queue->job([$exporter, 'exportToCSV'], $params)
    ->setName('monthly-report-export')
    ->setPriority('normal')
    ->setTimeout(7200) // 2 hours
    ->dispatch();
```

### 5. Image Processing Queue

[](#5-image-processing-queue)

```
class ImageProcessor {
    public function processImage(string $path, array $options) {
        // Image processing logic
    }
}

// Queue image processing
$processor = new ImageProcessor();
$options = [
    'resize' => true,
    'width' => 800,
    'height' => 600,
    'optimize' => true
];

$queue->job([$processor, 'processImage'], $options)
    ->setName('image-processing')
    ->setPriority('low')
    ->setMaxRetries(2)
    ->dispatch();
```

### 6. Calling global function without classes

[](#6-calling-global-function-without-classes)

```
function exportCsvData(string $filePath) {
    // Process to export data
}

// Queue file export processing
$queue->job('exportCsvData', $filePath)
    ->setIncludePathFile('/path/to/csv_helpers.php') // Include the file before called the function
    ->dispatch();
```

### 7. Invokable Classes

[](#7-invokable-classes)

```
class MyInvokableClass {
    public function __invoke($param1, $param2) {
        // Invokable class logic
        echo "Processing invokable class with params: $param1, $param2";
    }
}

$invokable = new MyInvokableClass();
$processor->job($invokable, ['param1', 'param2'])
    ->dispatch();
```

⚙️ Configuration Options
------------------------

[](#️-configuration-options)

```
$config = [
    'process_check_interval' => 1000000,  // Worker check interval (microseconds)
    'worker_timeout' => 3600,            // Worker timeout (seconds)
    'max_workers' => 1,                  // Maximum number of concurrent workers
    'lock_dir' => '/tmp'                 // Directory for worker lock files
];

$queue = new JobProcessor($connection, $config);
```

📊 Monitoring and Management
---------------------------

[](#-monitoring-and-management)

```
$processor = new JobProcessor($connection, $config);

// Get queue statistics
$stats = $processor->getJobStats();
print_r($stats);
/* Output:
[
    'total_jobs' => 100,
    'pending_jobs' => 10,
    'processing_jobs' => 5,
    'completed_jobs' => 80,
    'failed_jobs' => 5,
    'avg_processing_time' => 45.5
]
*/

// Get specific job status
$jobUuId = $processor->job($callable)->dispatch();
$status = $processor->getJobStatus($jobUuId);

// Retry failed jobs
$processor->retryAllFailed();

// Clear old failed jobs
$processor->clearFailedJobs(30); // Clear jobs older than 30 days
```

📅 Database Tables
-----------------

[](#-database-tables)

The package automatically creates two tables:

- `jobs` - Stores queue jobs
- `failed_jobs` - Stores failed job information

👍 Best Practices
----------------

[](#-best-practices)

1. **Job Naming**: Always set meaningful names for jobs using `setName()` for better tracking.
2. **Timeouts**: Set appropriate timeouts based on job complexity.
3. **Retries**: Configure max retries based on job criticality.
4. **Priority**: Use priorities wisely - reserve 'urgent' for truly time-critical tasks.

🔍 Error Handling
----------------

[](#-error-handling)

The package handles various types of errors:

- Connection failures
- Execution timeouts
- Runtime errors
- Worker process failures

Failed jobs are automatically logged with full stack traces in the `failed_jobs` table.

📛 Limitations
-------------

[](#-limitations)

- Windows support is limited for signal handling
- Maximum execution time is subject to PHP's `max_execution_time` setting
- Single-server deployment only (no distributed queue support)

📌 To-do Improvements
--------------------

[](#-to-do-improvements)

1. Implement job events/hooks
2. Add support for job batching
3. Add Redis/memory queue support
4. Add job progress tracking
5. Implement job middleware support
6. Add support for unique jobs
7. Add job chaining capabilities

🤝 Contributing
--------------

[](#-contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

📄 License
---------

[](#-license)

This project is licensed under the MIT License.

🏷️ Changelog
------------

[](#️-changelog)

 Click to view the changelog### v1.0.0

[](#v100)

- Initial release.

### v1.0.1

[](#v101)

- Removed `SerializableClosure` helper.
- Fixed CodeIgniter 3 table creation issues.
- Added support for `MY_Model` as a custom model for CodeIgniter 3.
- Added `opis/closure` library to support serializable closures.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance40

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

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 ~0 days

Total

2

Last Release

502d ago

PHP version history (2 changes)1.0.0PHP &gt;=7.4

1.0.1PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/55aa2d560832706c4e1025fd6552a5b1067eb56e60982e743a93490e8262fcf7?d=identicon)[faizzul95](/maintainers/faizzul95)

---

Top Contributors

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

---

Tags

laravelmysqlmssqloraclecodeigniterqueueframework agnosticjob queuedatabase-queue

### Embed Badge

![Health badge](/badges/onlyphp-simple-queue/health.svg)

```
[![Health](https://phpackages.com/badges/onlyphp-simple-queue/health.svg)](https://phpackages.com/packages/onlyphp-simple-queue)
```

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k578.4M5.6k](/packages/doctrine-dbal)[dg/adminer-custom

Customization for Adminer, the best database management tool written in PHP.

134765.7k16](/packages/dg-adminer-custom)[tommyknocker/pdo-database-class

Framework-agnostic PHP database library with unified API for MySQL, MariaDB, PostgreSQL, SQLite, MSSQL, and Oracle. Query Builder, caching, sharding, window functions, CTEs, JSON, migrations, ActiveRecord, CLI tools, AI-powered analysis. Zero external dependencies.

845.7k](/packages/tommyknocker-pdo-database-class)[moharrum/laravel-adminer

Adminer database management tool for your Laravel application.

451.0k](/packages/moharrum-laravel-adminer)[dg/adminer

Customization for Adminer, the best database management tool written in PHP.

1342.5k](/packages/dg-adminer)[ramadan/easy-model

A Laravel package for enjoyably managing database queries.

101.6k](/packages/ramadan-easy-model)

PHPackages © 2026

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