jascha030/process-chain

链式调用 symfony/process 命令。

1.0.1 2023-03-28 08:19 UTC

This package is auto-updated.

Last update: 2024-09-28 11:20:02 UTC


README

链式调用 symfony/process 命令。

入门

先决条件

  • php: >=8.1
  • Composer ^2.3

安装

composer require jascha030/process-chain

用法

<?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";
}

许可证

此Composer包是开源软件,受MIT许可证许可。