Files
nih-php-command-builder/example.php

27 lines
513 B
PHP

<?php
use Nih\CommandBuilder\Command;
use Nih\CommandBuilder\Stdio;
require_once __DIR__ . '/vendor/autoload.php';
$output = (new Command('echo'))
->arg('-n')
->arg('-')
->arg("./ \$wow '''/stdout.txt")
->stderr(Stdio::null())
->output();
var_dump($output);
$child = (new Command('/usr/bin/cat'))
->stdin(Stdio::piped('r'))
->spawn(shell: false);
$child->stdin?->write('Hello, this is pretty cool.');
$child->stdin?->close();
$output = $child->output();
var_dump($output);