public static function exec($command, array $params = array(), $mergeStdErr=true)
    {
        if (empty($command)) {
            throw new \InvalidArgumentException('Command line is empty');
        }

        $command = self::bindParams($command, $params);

        if ($mergeStdErr) {
            // Redirect stderr to stdout to include it in $output
            $command .= ' 2>&1';
        }

        exec($command, $output, $code);

        if (count($output) === 0) {
            $output = $code;
        } else {
            $output = implode(PHP_EOL, $output);
        }

        if ($code !== 0) {
            throw new CommandException($command, $output, $code);
        }

        return $output;
    }
public static function exec($command, array $params = array(), $mergeStdErr=true)
    {
        if (empty($command)) {
            throw new \InvalidArgumentException('Command line is empty');
        }

        $command = self::bindParams($command, $params);

        if ($mergeStdErr) {
            // Redirect stderr to stdout to include it in $output
            $command .= ' 2>&1';
        }

        exec($command, $output, $code);

        if (count($output) === 0) {
            $output = $code;
        } else {
            $output = implode(PHP_EOL, $output);
        }

        if ($code !== 0) {
            throw new CommandException($command, $output, $code);
        }

        return $output;
    }
public static function exec ( $ command , array $ params = array ( ) , $ mergeStdErr = true ) { if ( empty ( $ command ) ) { throw new \ InvalidArgumentException ( 'Command line is empty' ) ; } $ command = self :: bindParams ( $ command , $ params ) ; if ( $ mergeStdErr ) { // Redirect stderr to stdout to include it in $output $ command .= ' 2>&1' ; } exec ( $ command , $ output , $ code ) ; if ( count ( $ output ) === 0 ) { $ output = $ code ; } else { $ output = implode ( PHP_EOL , $ output ) ; } if ( $ code !== 0 ) { throw new CommandException ( $ command , $ output , $ code ) ; } return $ output ; }
Execute command with params.

@param string $command
@param array  $params

@return bool|string

@throws \Exception
Execute command with params .