Download the PHP package dalehurley/process-manager without Composer
On this page you can find all versions of the php package dalehurley/process-manager. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dalehurley/process-manager
More information about dalehurley/process-manager
Files in dalehurley/process-manager
Package process-manager
Short Description A lightweight parallel process runner for PHP. Execute multiple scripts concurrently with configurable parallelism, timeouts, and result tracking.
License MIT
Homepage https://github.com/dalehurley/PHP-Process-Manager
Informations about the package process-manager
PHP Process Manager
A lightweight parallel process runner for PHP. Execute multiple scripts or commands concurrently with configurable parallelism, timeouts, and real-time output tracking.
Overview
What is it?
PHP Process Manager is a concurrent task runner that spawns and manages multiple OS processes simultaneously. Instead of running tasks one after another (sequential), it executes them in parallel—dramatically reducing total execution time for batch operations.
Think of it as a simple process pool or worker spawner: you queue up scripts, set a concurrency limit, and the manager handles execution, monitoring, timeouts, and result collection.
Who is it for?
| Audience | Use Case |
|---|---|
| Backend developers | Batch processing, data imports/exports, scheduled jobs |
| DevOps engineers | Deployment scripts, server maintenance, multi-host operations |
| Data engineers | ETL pipelines, file processing, API data collection |
| QA engineers | Parallel test execution, load testing preparation |
| System administrators | Bulk operations, log processing, backup scripts |
Why use it?
PHP is single-threaded by default. When you have independent tasks, running them sequentially wastes time:
| Scenario | Sequential | Parallel (5 workers) | Speedup |
|---|---|---|---|
| 10 API calls × 2s each | 20s | ~4s | 5× |
| 100 file imports × 1s each | 100s | ~20s | 5× |
| 50 email sends × 0.5s each | 25s | ~5s | 5× |
This package is ideal when you need to:
- Run the same script multiple times with different inputs
- Execute multiple independent scripts as part of a workflow
- Process batches of work faster by parallelising
- Add timeout protection to unreliable external calls
- Limit concurrency to avoid overwhelming external services
When to use it (and when not to)
✅ Good fit:
- Tasks are independent and don't share state
- Each task can run as a separate PHP script or CLI command
- You need timeout protection for unreliable tasks
- You want to limit concurrency (e.g., max 5 API calls at once)
- Tasks take seconds to minutes to complete
❌ Consider alternatives for:
- Tasks requiring shared memory or real-time inter-process communication → use parallel extension
- Web request handling with high throughput → use a message queue (Redis, RabbitMQ, SQS)
- Sub-second task spawning at high frequency → process overhead becomes significant
- Long-running daemon processes → use Supervisor or systemd instead
Real-World Use Cases
1. Batch Data Import
Import thousands of records by processing files in parallel:
2. Multi-API Data Collection
Fetch data from multiple APIs simultaneously:
3. Image/Video Processing Pipeline
Process media files in parallel using CLI tools:
4. Database Migration Runner
Run independent migrations concurrently:
5. Parallel Test Execution
Run test suites faster:
6. Multi-Server Deployment
Deploy to multiple servers simultaneously:
Features
- 🚀 Concurrent Execution - Run multiple processes in parallel
- ⏱️ Timeout Management - Automatically kill processes that exceed time limits
- 📊 Result Tracking - Get detailed results for each process (exit codes, output, timing)
- 🎨 Flexible Output - Console, HTML, or custom output handlers
- 🔧 Fluent API - Chain configuration methods for clean setup
- 🏷️ Fully Typed - PHP 8.2+ with strict typing and readonly classes
Requirements
- PHP 8.2 or higher
proc_openfunction enabled
Installation
Via Composer
Manual Installation
Clone the repository and include the autoloader:
Quick Start
Usage
Basic Configuration
Fluent API
Adding Scripts
Output Handlers
The package includes several output handlers:
Custom Output Handler
Implement the OutputHandlerInterface for custom output:
Working with Results
API Reference
ProcessManager
| Method | Description |
|---|---|
setExecutable(string $executable) |
Set the command to execute |
setWorkingDirectory(string $path) |
Set the working directory |
setMaxConcurrentProcesses(int $count) |
Set max parallel processes |
setSleepInterval(int $seconds) |
Set interval between status checks |
setOutputHandler(OutputHandlerInterface $handler) |
Set the output handler |
addScript(string $script, ...) |
Add a script to the queue |
addScripts(array $scripts) |
Add multiple scripts |
getQueueCount() |
Get number of queued scripts |
getRunningCount() |
Get number of running processes |
clearQueue() |
Clear the script queue |
run() |
Execute all queued scripts |
ProcessResult
| Property | Type | Description |
|---|---|---|
script |
string |
Script name |
exitCode |
int |
Process exit code |
output |
string |
stdout content |
errorOutput |
string |
stderr content |
elapsedTime |
int |
Execution time in seconds |
wasKilled |
bool |
Whether process was killed |
wasSuccessful |
bool |
Whether process succeeded |
Upgrading from v1.x
The 2.0 release is a complete rewrite with breaking changes:
Key Changes
- Namespace:
DaleHurley\ProcessManager - Class renamed:
Processmanager→ProcessManager - Method renamed:
exec()→run() - Property renamed:
root→workingDirectory - Property renamed:
processes→maxConcurrentProcesses - Output handling now uses dedicated handler classes
- Returns detailed
ProcessResultobjects instead of void
Testing
Run the test suite with PHPUnit:
Run static analysis with PHPStan (level 8):
Alternatives
This package is intentionally simple and lightweight. Depending on your needs, consider these alternatives:
For More Complex Process Management
| Package | Description | Best For |
|---|---|---|
| symfony/process | Full-featured process component | Single process with advanced I/O handling |
| spatie/async | Asynchronous process handling with Pool | Similar use case with event-driven API |
| amphp/parallel | True parallel execution with workers | High-performance async applications |
For Queue-Based Processing
| Package | Description | Best For |
|---|---|---|
| Laravel Queues | Queue system with multiple backends | Laravel applications, distributed workers |
| Symfony Messenger | Message bus with queue transport | Symfony applications, event-driven |
| php-enqueue | Framework-agnostic queue abstraction | Multi-backend queue support |
| Beanstalkd + Pheanstalk | Lightweight job queue | Simple job queuing |
For True Multi-Threading
| Package | Description | Best For |
|---|---|---|
| parallel | PHP extension for parallel execution | Shared memory, true threading (requires ZTS PHP) |
| pthreads | Threading extension (PHP 7 only) | Legacy threading needs |
When to Choose This Package
Choose PHP Process Manager when you need:
- ✅ Simple, zero-dependency process spawning
- ✅ Quick setup without infrastructure (no Redis, no queue server)
- ✅ Timeout management built-in
- ✅ Result collection from all processes
- ✅ CLI script orchestration
- ✅ Lightweight alternative to full queue systems
Choose alternatives when you need:
- ❌ Persistent job storage and retry logic → use queues
- ❌ Distributed processing across servers → use message queues
- ❌ Shared memory between tasks → use parallel extension
- ❌ Web-scale throughput → use dedicated worker systems
License
MIT License. See LICENSE for details.
Credits
- Original concept by Matou Havlena (havlena.net)
- Modernized by Dale Hurley (dalehurley.com)
All versions of process-manager with dependencies
ext-pcntl Version *