Exemplo n.º 1
0
 /**
  * Execute command
  *
  * @param  InputInterface  $input  Input instance
  * @param  OutputInterface $output Output instance
  *
  * @return int|null|void
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $versionList = array();
     // ############################
     // System (LSB Version)
     // ############################
     $versionRow = array('system' => 'System', 'version' => UnixUtility::lsbSystemDescription());
     $versionList[] = array_values($versionRow);
     // ############################
     // PHP
     // ############################
     $versionList[] = array('PHP', phpversion());
     // ############################
     // MySQL
     // ############################
     $query = 'SHOW VARIABLES LIKE \'version\'';
     $versionRow = DatabaseConnection::getList($query);
     $versionList[] = array('MySQL', $versionRow['version']);
     // ############################
     // Apache
     // ############################
     $versionRow = array('system' => 'Apache', 'version' => 'Unknown');
     $command = new CommandBuilder('apache2ctl', '-v');
     $command->setOutputRedirect(CommandBuilder::OUTPUT_REDIRECT_NO_STDERR);
     $execOutput = $command->execute()->getOutput();
     foreach ($execOutput as $execOutputLine) {
         if (strpos($execOutputLine, ':') !== false) {
             list($tmpKey, $tmpVersion) = explode(':', trim($execOutputLine), 2);
             switch (strtolower($tmpKey)) {
                 case 'server version':
                     $versionRow['version'] = trim($tmpVersion);
                     break;
             }
         }
     }
     $versionList[] = array_values($versionRow);
     // ############################
     // Docker
     // ############################
     $versionRow = array('system' => 'Docker', 'version' => \CliTools\Utility\UnixUtility::dockerVersion());
     $versionList[] = array_values($versionRow);
     // ############################
     // CliTools
     // ############################
     $versionList[] = array('CliTools', CLITOOLS_COMMAND_VERSION);
     // ########################
     // Output
     // ########################
     /** @var \Symfony\Component\Console\Helper\Table $table */
     $table = new Table($output);
     $table->setHeaders(array('System', 'Version'));
     foreach ($versionList as $versionRow) {
         $table->addRow(array_values($versionRow));
     }
     $table->render();
     return 0;
 }