Download the PHP package nusje2000/process-runner without Composer
On this page you can find all versions of the php package nusje2000/process-runner. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nusje2000/process-runner
More information about nusje2000/process-runner
Files in nusje2000/process-runner
Package process-runner
Short Description A simple package for running multiple processes within a PHP process.
License MIT
Informations about the package process-runner
Process runner
This package provides simple services to run commands within a php process.
Each set of commands is called a TaskList
and each TaskList contains a set of Tasks. A TaskList
can be processed
by an Executor
which takes the commands from each task and runs it.
Creating a TaskList
The creation of a tasklist can be done manually like this:
Or using the provided factory for simple task lists:
Executing a TaskList
The execution of command is done by an Executor, this package provides two executors: ParallelExecutor and SequentialExecutor.
You can try them by running php vendor/nusje2000/process-runner/bin/example.php
. This runs a set of commands using
both the sequential and parallel executor.
Using the parallel executor
The ParallelExecutor runs all the tasks at the same time.
Using the sequential executor
The SequentialExecutor runs all the tasks after each other.
Listening for process updates
Sometimes the output from commands must be used within the parent process. This can be done by using a listener. Each listener has an onTick function which is called when the child process state is checked.
Creating a listener using the callback listener
If you want to add a simple listen function to an executor than the CallbackListener can be used. This takes a callback as argument and then uses that callback as tick function.
Creating a listener using the ExecutionListener interface
Sometimes a listener is too complicated for a simple callback function, in this case you can create your own class that implements the ExecutionListener interface to handle the tick.
Forwarding the status of the tasks to the console
In most cases the parent process is a command as well. If you want to see the status of the child processes in the output of the parent process, you can add the ConsoleListener to the executor. This will show a list of all the tasks with their status and in case of an error, it will show the output and error output of the child process.
The output of the listener will look something like this:
Using the console listener in situations where the output is logged
Is some situations (like ci/cd integrations), the output of console commands is logged to files. If this is the case, using the default ConsoleLogger would result in output for each process change check (by default 5 times a second). For these usecases, you can use the StaticConsoleListener. This listener will only print the changes to the console, instead of updating the console output using sections.
The output of the listener will look something like this:
All versions of process-runner with dependencies
symfony/process Version ^4.4|^5.0|^6.0
symfony/console Version ^4.4|^5.0|^6.0
ramsey/uuid Version ^4.1