/** * @param string $command * @param null $errorMessage * @param bool|false $silent * @param bool|true $abortOnError * * @return Response * @throws ShellException */ public function execCommand($command, $errorMessage = null, $silent = false, $abortOnError = true) { trim($command); if (!$silent || $this->verbose) { $this->getLogger()->log('code', trim(sprintf('%s %s', $this->getPrompt(), $command))); } $lastLine = exec($command, $output, $res); if (!is_array($output)) { $output = []; } $response = new Response($res, $output, $lastLine, $command); if ($abortOnError && $response->getReturnCode()) { throw new ShellException(empty($errorMessage) ? $response->getOutputAsString() : $errorMessage, $response->getReturnCode()); } return $response; }