PHPackages                             ereborcodeforge/mithrilexecutor - 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. ereborcodeforge/mithrilexecutor

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

ereborcodeforge/mithrilexecutor
===============================

Lightweight PHP background job runner with filesystem queue, daemon mode, and pluggable resolvers (no dependencies).

v2.0.1(4mo ago)15MITPHPPHP &gt;=8.1

Since Sep 13Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/Thalesrup/MithrilExecutor)[ Packagist](https://packagist.org/packages/ereborcodeforge/mithrilexecutor)[ Docs](https://github.com/Thalesrup/MithrilExecutor)[ RSS](/packages/ereborcodeforge-mithrilexecutor/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (8)Used By (0)

MithrilExecutor
===============

[](#mithrilexecutor)

Simple, dependency-free PHP background job runner using filesystem queues.

🚀 Quick Start
-------------

[](#-quick-start)

### 1. Create a Task Class

[](#1-create-a-task-class)

Any PHP class can be a job. No interface required.

```
// src/Tasks/EmailTask.php
namespace App\Tasks;

class EmailTask {
    public function __construct(private string $apiKey) {}

    public function send(string $to, string $subject): void {
        // Send email logic...
        echo "Email sent to $to";
    }
}
```

### 2. Enqueue a Job (Programmatic)

[](#2-enqueue-a-job-programmatic)

Use this in your application (Controller, Service, etc) to dispatch jobs.

```
use MithrilExecutor\Queue\FileJobQueue;
use MithrilExecutor\ValueObjects\Job;
use App\Tasks\EmailTask;

// Setup
$queue = new FileJobQueue(__DIR__ . '/storage');

// Create Job
$job = new Job(
    id: uniqid('job-'),
    className: EmailTask::class,
    constructorArgs: ['my-api-key'], // Passed to __construct
    calls: [
        [
            'method' => 'send',
            'args' => ['user@example.com', 'Welcome!'] // Passed to method
        ]
    ]
);

// Dispatch
$queue->enqueue($job);
```

### 3. Run the Worker (Terminal)

[](#3-run-the-worker-terminal)

Start the supervisor to process jobs.

```
php bin/mithril daemon --bootstrap=example/bootstrap.php --concurrency=4 --memory=128M
```

---

🛠 CLI Reference &amp; Flags
---------------------------

[](#-cli-reference--flags)

### Global Flags (Available for most commands)

[](#global-flags-available-for-most-commands)

FlagDescription`--bootstrap`Path to a PHP file that returns a `ResolverInterface`. Used to load your application's autoloader or DI container. **Optional** if your jobs are already autoloaded by Composer in the project root.`--storage`Custom path to the storage directory (defaults to `storage/`).### `daemon`

[](#daemon)

Starts the worker loop (supervisor). Recommended for production.

FlagDefaultDescriptionExample`--concurrency``1`Number of parallel worker processes to spawn.`--concurrency=5``--memory``null`Memory limit **per process** (passed to `ini_set` or PHP CLI).`--memory=256M``--sleep``250`Sleep time (ms) when queue is empty to reduce CPU usage.`--sleep=1000``--bootstrap``null`Autoloader/Resolver file (see Global Flags).`--bootstrap=autoload.php`**Example:**

```
# Runs 5 workers, each limited to 128MB RAM, loading classes from bootstrap.php
php bin/mithril daemon --concurrency=5 --memory=128M --bootstrap=src/bootstrap.php
```

### `list`

[](#list)

Lists jobs in the queue.

FlagOptionsDescriptionExample`--status``pending`, `running`, `done`, `failed`Filter jobs by status. Default shows all.`--status=failed``--format``table` (default), `json`, `csv`Output format. JSON/CSV are good for scripts.`--format=json``--output``null`Write output to a file instead of the screen.`--output=report.csv`**Example:**

```
# Export all failed jobs to a CSV file
php bin/mithril list --status=failed --format=csv --output=failed_jobs.csv
```

### `work`

[](#work)

Processes a **single** job and exits. Useful for cron jobs or one-off tasks.

FlagDescription`--quiet`Suppress "No job found" and "Running worker" logs. Useful for cron to avoid spamming emails.`--memory`Set memory limit for this specific run.**Example:**

```
php bin/mithril work --memory=512M --quiet --bootstrap=autoload.php
```

### `run`

[](#run)

Executes a specific job file directly (bypassing the queue logic). Useful for debugging a failed job file manually.

FlagDescription`--file`**Required**. Absolute path to the `.json` job file to execute.**Example:**

```
php bin/mithril run --file=/path/to/storage/queue/failed/job-123.json --bootstrap=autoload.php
```

### `enqueue`

[](#enqueue)

Enqueue a job via CLI (useful for testing).

FlagDescription`--class`Full class name of the job.`--ctor`JSON array of arguments for the constructor.`--calls`JSON array of method calls: `[{"method":"name","args":[...]}]`.**Example:**

```
php bin/mithril enqueue \
  --class="App\Tasks\EmailTask" \
  --ctor='["api-key"]' \
  --calls='[{"method":"send","args":["thales@example.com","Hello"]}]'
```

---

📂 Directory Structure
---------------------

[](#-directory-structure)

- `bin/mithril`: The CLI executable.
- `storage/queue`: Where pending/running/done jobs are stored as JSON.
- `src/`: The library source code.
- `example/`: Demo files.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance74

Regular maintenance activity

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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

Total

5

Last Release

146d ago

Major Versions

v0.1.0 → v2.0.02025-12-23

### Community

Maintainers

![](https://www.gravatar.com/avatar/8f5abcef1798019113953fcf9c64d1cd0ea51daaed285543dbb4ad340ddbda18?d=identicon)[Thalesrup](/maintainers/Thalesrup)

---

Top Contributors

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

---

Tags

phpfilesystemqueuejobbackgroundworkerdaemontask-runner

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ereborcodeforge-mithrilexecutor/health.svg)

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

###  Alternatives

[mjphaynes/php-resque

Redis backed library for creating background jobs and processing them later.

228199.3k2](/packages/mjphaynes-php-resque)[renoki-co/horizon-exporter

Export Laravel Horizon metrics using this Prometheus exporter.

24152.7k](/packages/renoki-co-horizon-exporter)

PHPackages © 2026

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