PHPackages                             mach3builders/mach3queue - 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. mach3builders/mach3queue

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

mach3builders/mach3queue
========================

A php queue system

1.3.1(2mo ago)0269PHPCI passing

Since Mar 9Pushed 2mo ago7 watchersCompare

[ Source](https://github.com/mach3builders/mach3queue)[ Packagist](https://packagist.org/packages/mach3builders/mach3queue)[ RSS](/packages/mach3builders-mach3queue/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (12)Versions (44)Used By (0)

mach3queue
==========

[](#mach3queue)

A php queue system

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

[](#installation)

First, add the package in composer.

```
{
  "require": {
    "mach3builders/mach3queue": "^1.1"
  },
}
```

```
composer install
```

Now run the following command to publish the configuration file.

```
./vendor/bin/queue publish
```

In the root of your project you will find a new file called `queue.php`. In this file you can setup the supervisors and the workers for the queue. The config file explains itself. You have to at least change the bootstrap location to your own bootstrap file so that your whole application is accessible from the queue, this has to be a absolute path.

```
'bootstrap' => __DIR__.'/vendor/bootstrap.php',
```

Then in your own bootstrap you need to configure the queue so you can access it in your application.

```
use Mach3queue\Queue\QueueManager as Queue;

$queue = new Queue;
$queue->setConnection([
    'driver' => 'mysql',
    'host' => 'localhost',
    'database' => 'database',
    'username' => 'username',
    'password' => 'password',
]);
```

Now because the queue has access to your database, run the following command to install the database tables.

```
./vendor/bin/queue install
```

Usage
-----

[](#usage)

To add a new job to the queue you can use the `add` method. This will add the given queueable to the default queue.

```
use Mach3queue\Queue\QueueManager as Queue;

Queue::addJob(new Queueable);
```

To add a job to a specific queue you can use the `on` method.

```
use Mach3queue\Queue\QueueManager as Queue;

Queue::on('deploy')->addJob(new Queueable)
```

To create a new queueable your class needs to implement the `Mach3queue\Queue\Queueable`. If you need to pass data to you `Queueable` you can do so through the `__construct` method.

```
use Mach3queue\Queue\Queueable;

class FakeEmptyQueueable implements Queueable
{
    public int $id;

    public function __construct(int $id)
    {
        $this->id = $id;
    }

    public function handle(): void
    {
        // Do something with the id
    }
}
```

### After event

[](#after-event)

You can add a method to the job to be executed after the job has finished. With this you can use your own logic after a job has either succeeded or failed.

```
use Mach3queue\Job;
use Mach3queue\Queue\QueueManager as Queue;

Queue::addJob(new Queueable)
    ->after(function (Job $job) {
        // Do something
    });
```

The job has a method called status that will return an enum of the status of the job.

```
use Mach3queue\Job;
use Mach3queue\Job\Status;

$job->status();

// Returns: Mach3queue\Job\Status
Status::COMPLETED;
Status::FAILED;

// these also exists, but will probably never be the case in the after call.
Status::PROCESSING;
Status::PENDING;
Status::UNKNOWN;
```

### Before job hook

[](#before-job-hook)

Long-running workers can experience stale database connections (e.g. `MySQL server has gone away`). The `before_job` config option lets you run a callback before each job to reconnect or do other setup.

In your `queue.php` config:

```
'before_job' => function () {
    // Reconnect your application's own database connection
    YourApp\Database::reconnect();
},
```

The callback receives the `Job` instance if you need to inspect it:

```
'before_job' => function (\Mach3queue\Job\Job $job) {
    Log::info("About to process job {$job->id} on queue {$job->queue}");
},
```

Dashboard
---------

[](#dashboard)

The package comes with a dashboard to monitor the queue. To view it you can get the html from it through the following code:

```
use Mach3queue\Dashboard\Dashboard;

echo Dashboard::parse();
```

Make this accessible to view where you want within your own application. If you want the jobs to show information about your `Queueable` you have to make the properties public. All public properties will be shown as a label.

Commands
--------

[](#commands)

These are the commands you can run in the terminal to manage the queue.

```
# To publish the configuration file

./vendor/bin/queue publish
```

```
# To prepare the database

./vendor/bin/queue install
```

```
# To start the queue

./vendor/bin/queue start
```

```
# To gracefully stop all the current queues and create
# new workers with the new state of your application.

./vendor/bin/queue restart
```

```
# To gracefully stop the whole queue system.

./vendor/bin/queue terminate
```

---

Deamon on a server
------------------

[](#deamon-on-a-server)

To run and monitor the queue on a server on a production environment we need to install and configure `supervisor`. It is a process monitor for the Linux operating system, and will automatically restart the queue when it is stopped.

### installation

[](#installation-1)

To install it on an Ubuntu server, you can use the following command.

```
sudo apt-get install supervisor
```

### Configuration

[](#configuration)

To configure the supervisor you need to create a new file in the `/etc/supervisor/conf.d` directory. You can name the file whatever you want, but it needs to have the `.conf` extension. This is a configuration file for the supervisor that you can use.

```
[program:queue]
process_name=%(program_name)s
command=php /home/websites/example.com/vendor/bin/queue start
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/home/websites/example.com/queue.log
stopwaitsecs=3600
```

Make sure the `stopwaitsecs` is set to a high number so that the queue has time to finish the jobs before it is stopped. See  for more information on the configuration.

### Starting the supervisor

[](#starting-the-supervisor)

After you have created the configuration file you can start the supervisor with the following commands.

```
sudo supervisorctl reread

sudo supervisorctl update

sudo supervisorctl start queue
```

For full documentation on supervisor see

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance86

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 97.9% 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 ~18 days

Recently: every ~5 days

Total

41

Last Release

74d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1c933de3316dff6b15b9b876af2f0a9719f27df19223b1f4aa801fcd0f30eb09?d=identicon)[Mach3Builders](/maintainers/Mach3Builders)

---

Top Contributors

[![rnewalsing](https://avatars.githubusercontent.com/u/8723578?v=4)](https://github.com/rnewalsing "rnewalsing (92 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/mach3builders-mach3queue/health.svg)

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

###  Alternatives

[illuminate/queue

The Illuminate Queue package.

20331.4M1.2k](/packages/illuminate-queue)[hellogerard/jobby

Manage all your cron jobs without modifying crontab. Handles locking, logging, error emails, and more.

1.1k1.6M14](/packages/hellogerard-jobby)[jolicode/castor

A lightweight and modern task runner. Automate everything. In PHP.

53541.0k3](/packages/jolicode-castor)[hyperf/xxl-job-incubator

php hyperf xxljob

4632.2k5](/packages/hyperf-xxl-job-incubator)[yiicod/yii2-jobqueue

Yii Job Queue based on Illuminate Queue

107.3k](/packages/yiicod-yii2-jobqueue)

PHPackages © 2026

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