Skip to content

ProcessQueue

github-actions edited this page Apr 17, 2026 · 1 revision

Executes queued processes sequentially while supporting detached entries and optional failure suppression.

Regular processes are executed in the order they were added and block the queue until completion. Detached processes are started in the order they were added but do not block subsequent entries.

A detached process that starts successfully is considered dispatched. Because this implementation does not wait for detached processes to finish during run(), their eventual runtime exit status cannot be incorporated into the final queue result. However, a detached process that cannot be started at all is treated as a startup failure and MAY affect the final status code unless its failure is explicitly configured to be ignored.

To ensure detached processes finish gracefully without being killed when the main PHP script ends, the queue automatically registers a shutdown handler during instantiation that implicitly awaits all detached processes. They can also be awaited explicitly via wait().


Methods

__construct

Initializes the queue and secures child processes from early termination.

public __construct(): mixed

add

Adds a process to the queue.

public add(\Symfony\Component\Process\Process $process, bool $ignoreFailure = false, bool $detached = false): void

Parameters:

Parameter Type Description
$process \Symfony\Component\Process\Process the process instance that SHALL be added to the queue
$ignoreFailure bool indicates whether a failure of this process MUST NOT affect the final queue result
$detached bool indicates whether this process SHALL be started without blocking the next queued process

run

Runs the queued processes and returns the resulting status code.

public run(\Symfony\Component\Console\Output\OutputInterface $output = new \Symfony\Component\Console\Output\NullOutput()): int

The returned status code represents the first non-zero exit code observed among non-ignored blocking processes, or among non-ignored detached processes that fail to start. Detached processes that start successfully are not awaited iteratively inside run() and therefore do not contribute their eventual runtime exit code to the returned result.

Parameters:

Parameter Type Description
$output \Symfony\Component\Console\Output\OutputInterface the output used during execution

Return Value:

the final exit status code produced by the queue execution


wait

Waits for all detached processes to finish execution.

public wait(?\Symfony\Component\Console\Output\OutputInterface $output = new \Symfony\Component\Console\Output\NullOutput()): void

Parameters:

Parameter Type Description
$output ?\Symfony\Component\Console\Output\OutputInterface the output interface to which process output and diagnostics MAY be written

Clone this wiki locally