validate([ 'command' => ['sometimes', 'string'] ]); $result = Process::pipe(function (Pipe $pipe) { $pipe->command('ls -la'); // $pipe->command('grep -i "laravel"'); }, function (string $type, string $output) { echo $output; }); return [ 'successful' => $result->successful(), 'failed' => $result->failed(), 'exitCode' => $result->exitCode(), 'output' => $result->output(), 'errorOutput' => $result->errorOutput(), ]; // return '
'.$result->output().''; } }