示例#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;
 }
示例#2
0
    /**
     * Generate banner header
     *
     * @return string
     */
    protected function generateBannerHeader()
    {
        // INFO: you can use figlet command for generating ascii-art-text
        $logo = '
    ____  _______    __________    ____  ____  __  __________   ________   _    ____  ___
   / __ \\/ ____/ |  / / ____/ /   / __ \\/ __ \\/  |/  / ____/ | / /_  __/  | |  / /  |/  /
  / / / / __/  | | / / __/ / /   / / / / /_/ / /|_/ / __/ /  |/ / / /     | | / / /|_/ /
 / /_/ / /___  | |/ / /___/ /___/ /_/ / ____/ /  / / /___/ /|  / / /      | |/ / /  / /
/_____/_____/  |___/_____/_____/\\____/_/   /_/  /_/_____/_/ |_/ /_/       |___/_/  /_/

    ';
        $subline = '        Development VM :: ' . UnixUtility::lsbSystemDescription();
        // add color
        $lines = explode("\n", $logo);
        foreach ($lines as &$line) {
            $line = "" . $line;
        }
        $logo = implode("\n", $lines);
        $ret = $logo . "\n" . $subline;
        return $ret;
    }