stdin(Stdio::piped()) ->stdout(Stdio::piped()) ->spawn(); $child->stdin?->write('Hello, World!'); $output = $child->waitWithOutput(); var_dump($output); // object(Nih\CommandBuilder\Output)#6 (3) { // ["stdout"]=> // string(13) "Hello, World!" // ["stderr"]=> // NULL // ["code"]=> // object(Nih\CommandBuilder\ExitStatus)#4 (1) { // ["code"]=> // int(0) // } // } (new Command('echo')) ->arg('Hello, World!') ->stdout(Stdio::inherit()) ->status(); // Hello, World!