phacman/php-process

Compact version: Executes commands in sub-processes

v1.0.0 2023-10-28 09:51 UTC

This package is auto-updated.

Last update: 2024-05-28 11:19:00 UTC


README

The Process executes commands in sub-processes.

History with a list of original committers/commits: shortlog.txt

Getting Started

use PhacMan\Process\Exception\ProcessFailedException;
use PhacMan\Process\Process;

require dirname(__DIR__, 1).'/vendor/autoload.php';

$src = dirname(__DIR__).'/src';
$process = new Process(['ls', '-lsa', $src]);
$process->run();

// executes after the command finishes
if (!$process->isSuccessful()) {
    throw new ProcessFailedException($process);
}

echo $process->getOutput();

/*
total 88
 4 drwxrwxr-x 4 some some  4096 окт 28 12:38 .
 4 drwxrwxr-x 8 some some  4096 окт 28 12:42 ..
 4 drwxrwxr-x 2 some some  4096 окт 28 12:38 Exception
 4 -rw-rw-r-- 1 some some  2843 окт 28 12:38 ExecutableFinder.php
 4 -rw-rw-r-- 1 some some  2424 окт 28 12:38 InputStream.php
 4 -rw-rw-r-- 1 some some  2745 окт 28 12:38 PhpExecutableFinder.php
 4 -rw-rw-r-- 1 some some  2425 окт 28 12:38 PhpProcess.php
 4 drwxrwxr-x 2 some some  4096 окт 28 12:38 Pipes
52 -rw-rw-r-- 1 some some 52007 окт 28 12:38 Process.php
 4 -rw-rw-r-- 1 some some  1961 окт 28 12:38 ProcessUtils.php
*/

Resources