protected function _run($input)
    {
        $this->_output = '';
        $this->_errorOutput = '';

        $descriptors = array(
            0 => array('pipe', 'r'),
            1 => array('pipe', 'w'),
            2 => array('pipe', 'w'),
        );
        $pipes = array();

        $childProcess = proc_open($this->toCommandString(), $descriptors, $pipes);

        if (!is_resource($childProcess)) {
            throw new \RuntimeException('Unable to run command: ' . $this->toCommandString());
        }

        if (null !== $input) {
            fwrite($pipes[0], $input);
            fclose($pipes[0]);
        }

        $output = stream_get_contents($pipes[1]);
        fclose($pipes[1]);

        $errorOutput = stream_get_contents($pipes[2]);
        fclose($pipes[2]);

        $exitCode = proc_close($childProcess);

        // Run the piped command, if any
        if ($this->hasPipedCommand()) {
            $pipedCommand = $this->getPipedCommand();

            $pipedCommand->run($output);

            $output      = $pipedCommand->getOutput();
            $exitCode    = $pipedCommand->getExitCode();
            $errorOutput = $pipedCommand->getErrorOutput();
        }

        $this->_output = $output;
        $this->_errorOutput = $errorOutput;

        return $exitCode;
    }
protected function _run($input)
    {
        $this->_output = '';
        $this->_errorOutput = '';

        $descriptors = array(
            0 => array('pipe', 'r'),
            1 => array('pipe', 'w'),
            2 => array('pipe', 'w'),
        );
        $pipes = array();

        $childProcess = proc_open($this->toCommandString(), $descriptors, $pipes);

        if (!is_resource($childProcess)) {
            throw new \RuntimeException('Unable to run command: ' . $this->toCommandString());
        }

        if (null !== $input) {
            fwrite($pipes[0], $input);
            fclose($pipes[0]);
        }

        $output = stream_get_contents($pipes[1]);
        fclose($pipes[1]);

        $errorOutput = stream_get_contents($pipes[2]);
        fclose($pipes[2]);

        $exitCode = proc_close($childProcess);

        // Run the piped command, if any
        if ($this->hasPipedCommand()) {
            $pipedCommand = $this->getPipedCommand();

            $pipedCommand->run($output);

            $output      = $pipedCommand->getOutput();
            $exitCode    = $pipedCommand->getExitCode();
            $errorOutput = $pipedCommand->getErrorOutput();
        }

        $this->_output = $output;
        $this->_errorOutput = $errorOutput;

        return $exitCode;
    }
protected function _run ( $ input ) { $ this -> _output = '' ; $ this -> _errorOutput = '' ; $ descriptors = array ( 0 => array ( 'pipe' , 'r' ) , 1 => array ( 'pipe' , 'w' ) , 2 => array ( 'pipe' , 'w' ) , ) ; $ pipes = array ( ) ; $ childProcess = proc_open ( $ this -> toCommandString ( ) , $ descriptors , $ pipes ) ; if ( ! is_resource ( $ childProcess ) ) { throw new \ RuntimeException ( 'Unable to run command: ' . $ this -> toCommandString ( ) ) ; } if ( null !== $ input ) { fwrite ( $ pipes [ 0 ] , $ input ) ; fclose ( $ pipes [ 0 ] ) ; } $ output = stream_get_contents ( $ pipes [ 1 ] ) ; fclose ( $ pipes [ 1 ] ) ; $ errorOutput = stream_get_contents ( $ pipes [ 2 ] ) ; fclose ( $ pipes [ 2 ] ) ; $ exitCode = proc_close ( $ childProcess ) ; // Run the piped command, if any if ( $ this -> hasPipedCommand ( ) ) { $ pipedCommand = $ this -> getPipedCommand ( ) ; $ pipedCommand -> run ( $ output ) ; $ output = $ pipedCommand -> getOutput ( ) ; $ exitCode = $ pipedCommand -> getExitCode ( ) ; $ errorOutput = $ pipedCommand -> getErrorOutput ( ) ; } $ this -> _output = $ output ; $ this -> _errorOutput = $ errorOutput ; return $ exitCode ; }
Actually run this command and its piped commands chain, if applicable.
Return the exit code for such execution.

@throws \RuntimeException If unable to run the command.

@param  string $input Input to this command.

@return int
Actually run this command and its piped commands chain if applicable . Return the exit code for such execution .