jascha030/process-chain

Chain symfony/process commands together.

1.0.1 2023-03-28 08:19 UTC

This package is auto-updated.

Last update: 2024-03-28 10:18:42 UTC


README

Chain symfony/process commands together.

Getting started

Prerequisites

  • php: >=8.1
  • Composer ^2.3

Installation

composer require jascha030/process-chain

Usage

<?php

use Jascha030\Process\Chain\ProcessChain;
use Symfony\Component\Console\Output\ConsoleOutput;

// Define the commands to run in the process chain
$commands = [
    'echo "Hello"',
    'echo "World"',
];

// Create a new instance of the ProcessChain class
$processChain = ProcessChain::create(
    $commands,
    new ConsoleOutput()
);

// Disable output for the processes in the chain
$processChain->disableOutput();

// Run the processes in the chain
$processChain->mustRun();

// Get the exit codes for the processes in the chain
$exitCodes = $processChain->getExitCodes();

// Output the exit codes for each command
foreach ($exitCodes as $command => $exitCode) {
    echo "{$command} exited with code {$exitCode}\n";
}

License

This composer package is an open-sourced software licensed under the MIT License