src/Synapse/CliCommand/CliCommandExecutor.php
public function execute($command = '', $cwd = null, array $env = null)
    {
        $fd = proc_open(
            $command,
            $this->descriptors,
            $pipes,
            $cwd,
            $env
        );

        // Close the proc's stdin right away
        fclose($pipes[0]);

        // Read stdout
        $output = $this->parseOutput(stream_get_contents($pipes[1]));
        fclose($pipes[1]);

        $returnCode = (int) trim(proc_close($fd));

        return new CliCommandResponse([
            'output'      => $output,
            'return_code' => $returnCode,
        ]);
    }
public function execute($command = '', $cwd = null, array $env = null)
    {
        $fd = proc_open(
            $command,
            $this->descriptors,
            $pipes,
            $cwd,
            $env
        );

        // Close the proc's stdin right away
        fclose($pipes[0]);

        // Read stdout
        $output = $this->parseOutput(stream_get_contents($pipes[1]));
        fclose($pipes[1]);

        $returnCode = (int) trim(proc_close($fd));

        return new CliCommandResponse([
            'output'      => $output,
            'return_code' => $returnCode,
        ]);
    }
public function execute ( $ command = '' , $ cwd = null , array $ env = null ) { $ fd = proc_open ( $ command , $ this -> descriptors , $ pipes , $ cwd , $ env ) ; // Close the proc's stdin right away fclose ( $ pipes [ 0 ] ) ; // Read stdout $ output = $ this -> parseOutput ( stream_get_contents ( $ pipes [ 1 ] ) ) ; fclose ( $ pipes [ 1 ] ) ; $ returnCode = ( int ) trim ( proc_close ( $ fd ) ) ; return new CliCommandResponse ( [ 'output' => $ output , 'return_code' => $ returnCode , ] ) ; }
Executes a cli command using proc_open

@param  string $command the command to be executed
@param  mixed  $cwd     the directory to execute in or null to use current
@param  mixed  $env     an array of environment variables or null to use current
@return CliCommandResponse a DataObject with output and return_code set
Executes a cli command using proc_open