public static function dump(Configuration $configuration)
 {
     $installer_wd = $configuration->get('base-path');
     $static_folder = $configuration->get('static-config');
     $config_file = $installer_wd . '/' . $static_folder . '/comodojo-config.yml';
     $configuration->set("authentication-key", self::generateKey())->set("private-key", self::generateKey())->set('cache-enabled', true)->set('cache-algorithm', 'pick-first')->set('startup-cache-enabled', true)->set('startup-cache-ttl', 86400);
     $configuration_array = $configuration->get();
     $yaml = Yaml::dump($configuration_array, 2);
     $action = file_put_contents($config_file, $yaml, LOCK_EX);
     if ($action === false) {
         throw new InstallerException("Cannot write comodojo-config file!");
     }
     return true;
 }
 private function loadInstallerConfig(Composer $composer)
 {
     $extra = $composer->getPackage()->getExtra();
     $installer_default_config = array('app-assets' => 'public/apps', 'theme-assets' => 'public/themes', 'local-cache' => 'cache', 'static-config' => 'config', 'local-logs' => 'logs', 'local-database' => 'database');
     if (isset($extra['comodojo-installer-paths']) && is_array($extra['comodojo-installer-paths'])) {
         $installer_config = array_replace($installer_default_config, $extra['comodojo-installer-paths']);
     } else {
         $installer_config = $installer_default_config;
     }
     $configuration = new Configuration();
     foreach ($installer_config as $setting => $value) {
         $configuration->set($setting, $value);
     }
     $configuration->set('base-path', getcwd());
     return $configuration;
 }
 public static function start(Configuration $configuration, IOInterface $io)
 {
     $params = array();
     $params['database-model'] = $io->ask("> Database model? (MYSQLI) ", "MYSQLI");
     $params['database-host'] = $io->ask("> Database host? (localhost) ", "localhost");
     $params['database-port'] = $io->askAndValidate("> Database port? (3306) ", function ($value) {
         return is_int($value);
     }, 3, 3306);
     $params['database-name'] = $io->ask("> Database name? (comodojo) ", "comodojo");
     $params['database-user'] = $io->ask("> Database user? (comodojo) ", "comodojo");
     $params['database-password'] = $io->askAndHideAnswer("> Database password? ");
     $params['database-prefix'] = $io->ask("> Common prefix for database tables? (cmdj_) ", "cmdj_");
     foreach ($params as $param => $value) {
         $configuration->set($param, $value);
     }
 }