PHPackages                             riki137/multitron - 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. riki137/multitron

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

riki137/multitron
=================

Tool for managing fast both asynchronous and multi-threaded execution of tasks. Focused on performance and pleasant CLI interface.

1.2.0(2mo ago)9016.8k↓23.7%1MITPHPPHP ^8.2CI passing

Since Jun 25Pushed 2mo ago5 watchersCompare

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

READMEChangelogDependencies (30)Versions (38)Used By (0)

Multitron: High-Performance PHP Task Orchestrator
=================================================

[](#multitron-high-performance-php-task-orchestrator)

[![Latest Version](https://camo.githubusercontent.com/42808bc223b4f44a513a8cf2944fb054b63d49c79a7ed0963ea0bcf1ca8e1e10/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72696b693133372f6d756c746974726f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/riki137/multitron)[![Total Downloads](https://camo.githubusercontent.com/d5cfb1e766fb9bbf2c4fc93991e93cd1ecf4a61a18bc1ef45fc86196b289e6e7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f72696b693133372f6d756c746974726f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/riki137/multitron)[![License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Build Status](https://camo.githubusercontent.com/e6e7b36a2e24ae36bc33ec94cf254ff7f4fe85f63d6604b3fd1216ee37fc4bbe/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f72696b693133372f6d756c746974726f6e2f63692e796d6c3f6272616e63683d6d6173746572267374796c653d666c61742d737175617265)](https://github.com/riki137/multitron/actions?query=workflow%3Aci+branch%3Amaster)[![Code Coverage](https://camo.githubusercontent.com/57d531ebab3652687539b8777ca0d546c19a1ae30d5dc9f361011018baa92d73/68747470733a2f2f636f6465636f762e696f2f67682f72696b693133372f6d756c746974726f6e2f6272616e63682f6d61737465722f67726170682f62616467652e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/gh/riki137/multitron)[![PHP Version](https://camo.githubusercontent.com/beb8642953b20f6843bcab00223550c452489b67be9e6b3ceaf2ccdbd62a3bdd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f72696b693133372f6d756c746974726f6e2e737667)](https://camo.githubusercontent.com/beb8642953b20f6843bcab00223550c452489b67be9e6b3ceaf2ccdbd62a3bdd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f72696b693133372f6d756c746974726f6e2e737667)[![PHPStan Level 9](https://camo.githubusercontent.com/fa7d257d0c5c1cf237ac3490ef3a5561626b17fcb0a8547c01b0bb8746554e60/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230392d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/fa7d257d0c5c1cf237ac3490ef3a5561626b17fcb0a8547c01b0bb8746554e60/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230392d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)

**Multitron** is a powerful, high-performance **PHP task orchestrator** designed to simplify parallel processing, concurrency, and automation in PHP applications. Quickly execute complex tasks asynchronously, maximizing the efficiency and scalability of your workflows.

**Ideal for Symfony Console apps, CI/CD pipelines, batch processing, and heavy PHP workloads.**

---

[![Multitron in Action](demo/kapture.gif)](demo/kapture.gif)

---

Table of Contents
-----------------

[](#table-of-contents)

- [Why Choose Multitron?](#why-choose-multitron)
- [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)
    - [Basic Example](#usage)
    - [Running Tasks](#usage)
    - [Central Cache](#central-cache)
    - [Reporting Progress](#reporting-progress)
    - [Partitioned Tasks](#partitioned-tasks)
    - [Accessing CLI Options](#accessing-cli-options)
    - [Custom Progress Output](#custom-progress-output)
- [Contributing](#contribute-to-multitron)
- [License](#license)

---

Why Choose Multitron?
---------------------

[](#why-choose-multitron)

- 🔄 **Efficient Task Dependency Management**: Clearly define task dependencies with intuitive declarative syntax.
- ⚡ **Optimized Parallel Execution**: Automatic CPU core detection for peak performance and resource utilization.
- 🧩 **Partitioned Workloads**: Easily split large tasks across multiple worker processes.
- 📊 **Real-Time Progress &amp; Transparency**: Continuous console logging and progress tracking.
- 🗄️ **Centralized Cache for Tasks**: Inter-process data sharing and communication made simple.
- 🔌 **Symfony Console Ready**: Effortlessly integrate Multitron into your existing Symfony-based applications.
- 📄 **Open Source &amp; MIT Licensed**: Completely free to use, adapt, and distribute.

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

[](#installation)

- [Symfony Integration](src/Bridge/Symfony/README.md)
- [Laravel Integration](src/Bridge/Laravel/README.md)
- [Native PHP Integration](src/Bridge/Native/README.md)
- [Nette Integration](src/Bridge/Nette/README.md)

Usage
-----

[](#usage)

Tasks implement the `Multitron\Execution\Task` interface. Here's a minimal example task:

```
use Multitron\Comms\TaskCommunicator;
use Multitron\Execution\Task;

final class HelloTask implements Task
{
    public function execute(TaskCommunicator $comm): void
    {
        $comm->log('Hello from a worker');
    }
}
```

You can register tasks in a command that extends `Multitron\Console\TaskCommand`:

```
use Multitron\Console\TaskCommand;
use Multitron\Tree\TaskNode;
use Multitron\Tree\TaskTreeBuilder;
use Symfony\Component\Console\Attribute\AsCommand;

#[AsCommand(name: 'app:tasks')]
final class MyCommand extends TaskCommand
{
    /**
     * @return TaskNode[]
     */
    public function getNodes(TaskTreeBuilder $b): array
    {
        return [
            $cache = $b->group('cache-clear', [
                $b->service(ClearCacheTask::class),
                $b->service(ClearLogsTask::class),
            ]),
            $b->service(AfterCacheClearTask::class, dependencies: [$cache]),
            $first = $b->service(MyFirstTask::class),
            $second = $b->service(MySecondTask::class, dependencies: [$first]),
            $anotherSecond = $b->service(MyAnotherSecondTask::class, dependencies: [$first]),
            $b->partitioned(MyPartitionedTask::class, 4, dependencies: [$second, $cache]),
        ];
    }
}
```

Register the command in your Symfony Console application and run it. Multitron will execute the tasks respecting dependencies and concurrency.

You can control how many tasks run at once via the `-c`/`--concurrency` option:

```
php bin/console app:tasks -c 8
```

The library will spawn up to eight worker processes and keep them busy until all tasks finish.

To limit which tasks run, pass a pattern as the first argument. Wildcards work the same as in `fnmatch()` and you may use `%` in place of `*` for convenience:

```
php bin/console app:tasks cache-* # run only tasks whose ID or tag matches "cache-*"
```

By default, Multitron will also include transitive dependencies of the matched tasks so the resulting execution graph stays valid. If you want to run only the matched tasks (and ignore dependencies outside the selection), use `--no-deps`:

```
php bin/console app:tasks cache-* --no-deps
```

You can combine multiple patterns by separating them with commas. The filter applies to both task IDs and tags and is an OR pattern.

```
php bin/console app:tasks "db-%,cache-%,final-%"
```

You can also tune how often progress updates are rendered using the `-u`/`--update-interval` option (in seconds):

```
php bin/console app:tasks -u 0.5
```

You may also constrain memory usage with the `-m`/`--memory-limit` option:

```
php bin/console app:tasks -m 512M
```

You can disable colors with `--no-colors` and switch off interactive table rendering using `--interactive=no`. The default `--interactive=detect` automatically falls back to plain output when run in CI.

### Central Cache

[](#central-cache)

Within a task you receive a `TaskCommunicator` instance that provides simple methods to read and write data shared between tasks:

```
use Multitron\Comms\TaskCommunicator;

final class MyTask implements Task
{
    public function execute(TaskCommunicator $comm): void
    {
        $comm->cache->write(['foo' => ['bar' => 'baz']]);
        $baz = $comm->cache->read(['foo' => ['bar']])->await()['foo']['bar']; // returns "baz"

        // Read existing values first, then update
        $existing = $comm->cache->read(['stats' => ['hits']])->await();
        $hits = $existing['stats']['hits'] ?? 0;
        $comm->cache->write(['stats' => ['hits' => $hits + 1]]);
    }
}
```

### Reporting Progress

[](#reporting-progress)

Tasks can update progress counters that Multitron displays while running. Use the `ProgressClient` provided by the communicator:

```
final class DownloadTask implements Task
{
    public function execute(TaskCommunicator $comm): void
    {
        $comm->progress->setTotal(100);
        for ($i = 0; $i < 100; $i++) {
            // ... work
            $comm->progress->addDone();
        }
    }
}
```

You may also call `addOccurrence()` or `addWarning()` to report additional metrics or warnings.

### Partitioned Tasks

[](#partitioned-tasks)

When a workload can be split into chunks, partitioned tasks run those chunks in parallel. Define a task extending `PartitionedTask` and specify the number of partitions in the tree:

```
use Multitron\Tree\Partition\PartitionedTask;

final class BuildReportTask extends PartitionedTask // or implements PartitionedTaskInterface, use PartitionedTaskTrait
{
    public function execute(TaskCommunicator $comm): void
    {
        $comm->log("processing part {$this->partitionIndex} of {$this->partitionCount}");
    }
}

$builder->partitioned(BuildReportTask::class, 4);
```

### Accessing CLI Options

[](#accessing-cli-options)

Options passed on the command line are forwarded to each task. Retrieve them via `TaskCommunicator`:

```
final class ProcessUsersTask implements Task
{
    public function execute(TaskCommunicator $comm): void
    {
        $limit = (int)($comm->getOption('limit') ?? 0);
        // ... process with the given $limit
    }
}
```

Call `getOptions()` to receive the entire array of options if needed.

### Custom Progress Output

[](#custom-progress-output)

Multitron renders progress using a `ProgressOutputFactory`. Replace the default table display or combine outputs with `ChainProgressOutputFactory`:

```
use Multitron\Orchestrator\Output\ChainProgressOutputFactory;
use Multitron\Orchestrator\Output\TableOutputFactory;
use Multitron\Bridge\Native\MultitronFactory;

$factory = new MultitronFactory();

$outputFactory = new ChainProgressOutputFactory(
    $factory->getProgressOutputFactory(),
    new JsonOutputFactory(), // your own class for custom output
);

$factory->setProgressOutputFactory($outputFactory);
```

Implement the factory to send progress anywhere you like.

---

Troubleshooting
---------------

[](#troubleshooting)

### "ext-pcntl is required"

[](#ext-pcntl-is-required)

Multitron requires the `pcntl` extension for process management. Install it:

```
# Ubuntu/Debian
sudo apt-get install php-pcntl

# macOS (usually included)
# If missing, use Homebrew PHP
brew install php
```

### Worker processes hang or timeout

[](#worker-processes-hang-or-timeout)

- Check the worker timeout setting (default 60s): ```
    $factory->setWorkerTimeout(300.0); // 5 minutes
    ```
- Ensure your tasks don't have infinite loops
- Check for deadlocks in IPC communication

### "WorkerCommand not found" error

[](#workercommand-not-found-error)

Make sure you've registered the worker command:

```
// Symfony - register extension in Kernel
$container->registerExtension(new MultitronExtension());

// Laravel - add to bootstrap/providers.php
MultitronServiceProvider::class,

// Native - add to application
$app->add($factory->getWorkerCommand());
```

### Memory limit errors

[](#memory-limit-errors)

Adjust the memory limit:

```
php bin/console app:tasks -m 1G
```

Or set it in your task command initialization.

### Tasks not running in parallel

[](#tasks-not-running-in-parallel)

- Check concurrency setting: `php bin/console app:tasks -c 8`
- Verify task dependencies aren't creating a serial execution path
- Ensure you have enough CPU cores available

### Progress not updating

[](#progress-not-updating)

- Check the update interval: `php bin/console app:tasks -u 0.5`
- In CI environments, use `--interactive=no` for plain output
- Verify you're calling `$comm->progress->addDone()` in your tasks

### Cache data not persisting between tasks

[](#cache-data-not-persisting-between-tasks)

- Ensure you're using `$comm->cache->write()` before `read()`
- Remember to call `->await()` on read promises
- Cache is process-scoped; it doesn't persist after the command finishes

For more help, check existing [GitHub Issues](https://github.com/riki137/multitron/issues) or open a new one.

---

Contribute to Multitron!
------------------------

[](#contribute-to-multitron)

Your feedback, issues, and contributions are highly encouraged. Open a GitHub issue or start a pull request to help improve PHP concurrency and task management:

- [Create an Issue](https://github.com/riki137/multitron/issues)
- [Submit a Pull Request](https://github.com/riki137/multitron/pulls)

---

License
-------

[](#license)

Multitron is MIT licensed. See the [LICENSE](LICENSE) file for full details.

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance86

Actively maintained with recent releases

Popularity39

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity64

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

Recently: every ~51 days

Total

16

Last Release

71d ago

Major Versions

0.2.0 → 1.0.0-beta12025-06-18

PHP version history (2 changes)0.1.0PHP ^8.1

1.0.0-beta1PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/1672f5f9f3ea6591c73db424f279144a4634bda6f8cfbd2038680394e8007ccd?d=identicon)[riki137](/maintainers/riki137)

---

Top Contributors

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

---

Tags

phpasyncconcurrencymulti-threadingworkflowbatch processingsymfony-consoleparallel-processingtask-runnertask-orchestratorprocess-management

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/riki137-multitron/health.svg)

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

###  Alternatives

[revolt/event-loop

Rock-solid event loop for concurrent PHP applications.

92343.6M138](/packages/revolt-event-loop)[amphp/parallel

Parallel processing component for Amp.

85046.2M74](/packages/amphp-parallel)[league/geotools

Geo-related tools PHP 7.3+ library

1.4k5.3M26](/packages/league-geotools)[toin0u/geotools

Geo-related tools PHP 7.3+ library

1.4k1.3k](/packages/toin0u-geotools)[badfarm/zanzara

Asynchronous PHP Telegram Bot Framework

2042.5k](/packages/badfarm-zanzara)[danog/ipc

IPC component for Amp.

11680.1k6](/packages/danog-ipc)

PHPackages © 2026

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