Files
nih-php-command-builder/examples/plumbing.php

18 lines
338 B
PHP

<?php
use Nih\CommandBuilder\Command;
use Nih\CommandBuilder\Stdio;
require_once __DIR__ . '/../vendor/autoload.php';
$echo = (new Command('echo'))
->arg('Hello, World!')
->stdout(Stdio::piped())
->spawn();
$cat = (new Command('cat'))
->stdin(Stdio::stream($echo->stdout))
->status();
// Prints "Hello, World!\n"