Search by

alcamo / process

rv1971

Classes for processes opened by proc_open()

0.5.4 2026-06-20 18:23 UTC

This package is auto-updated.

Last update: 2026-08-20 18:41:36 UTC


README

use alcamo\process\Process;

$process = new Process('echo Hello, world!');

$hello = $process->fgets();

Now $hello contains the string "Hello, world!" (plus the platform-dependent line break).

The usual PHP functions writing to or reading from streams can be used as magic methods on Process objects to write to / read from the child process's standard input/output.

A ProcessFactory class is provided to facilitate creating processes which all use the same underlying program. For instance:

use alcamo\process\ProcessFactory;

$gitFactory = new ProcessFactory('/home/alice', '/usr/bin/git');

$configProcess = $gitFactory->create('config -l');

$configData = $config->stream_get_contents();