Download the PHP package riki137/multitron without Composer
On this page you can find all versions of the php package riki137/multitron. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download riki137/multitron
More information about riki137/multitron
Files in riki137/multitron
Package multitron
Short Description Tool for managing fast both asynchronous and multi-threaded execution of tasks. Focused on performance and pleasant CLI interface.
License MIT
Homepage https://github.com/riki137/multitron
Informations about the package multitron
Multitron: High-Performance PHP Task Orchestrator
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.
Table of Contents
- Why Choose Multitron?
- Requirements
- Installation
- Usage
- Central Cache
- Reporting Progress
- Partitioned Tasks
- Accessing CLI Options
- Custom Progress Output
- Troubleshooting
- Contributing
- License
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 & 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 & MIT Licensed: Completely free to use, adapt, and distribute.
Installation
- Symfony Integration
- Laravel Integration
- Native PHP Integration
- Nette Integration
Usage
Tasks implement the Multitron\Execution\Task interface. Here's a minimal example task:
You can register tasks in a command that extends Multitron\Console\TaskCommand:
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:
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:
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:
You can combine multiple patterns by separating them with commas. The filter applies to both task IDs and tags and is an OR pattern.
You can also tune how often progress updates are rendered using the -u/--update-interval option (in seconds):
You may also constrain memory usage with the -m/--memory-limit option:
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.
Multitron warns when available system memory drops below a threshold (in MB) via --low-memory-warn. It defaults to 1024 MB; pass 0 to disable the warning:
Central Cache
Within a task you receive a TaskCommunicator instance that provides simple methods to read and write data shared between tasks:
Reporting Progress
Tasks can update progress counters that Multitron displays while running. Use
the ProgressClient provided by the communicator:
You may also call addOccurrence() or addWarning() to report additional
metrics or warnings.
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:
Accessing CLI Options
Options passed on the command line are forwarded to each task. Retrieve them via
TaskCommunicator:
Call getOptions() to receive the entire array of options if needed.
Custom Progress Output
Multitron renders progress using a ProgressOutputFactory. Replace the default table display or combine outputs with ChainProgressOutputFactory:
Implement the factory to send progress anywhere you like.
Troubleshooting
"ext-pcntl is required"
Multitron requires the pcntl extension for process management. Install it:
Worker processes hang or timeout
-
Check the worker timeout setting (default 60s):
- Ensure your tasks don't have infinite loops
- Check for deadlocks in IPC communication
"WorkerCommand not found" error
Make sure you've registered the worker command:
Memory limit errors
Adjust the memory limit:
Or set it in your task command initialization.
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
- Check the update interval:
php bin/console app:tasks -u 0.5 - In CI environments, use
--interactive=nofor plain output - Verify you're calling
$comm->progress->addDone()in your tasks
Cache data not persisting between tasks
- Ensure you're using
$comm->cache->write()beforeread() - 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 or open a new one.
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:
License
Multitron is MIT licensed. See the LICENSE file for full details.
All versions of multitron with dependencies
symfony/console Version ^7.2|^8.0
riki137/stream-ipc Version ^1.0
psr/container Version ^2.0
psr/container-implementation Version *