private function _create_config($config_file) { $this->_check_dir('/var/lib/' . $this->_project_name); $this->_check_dir('/var/cache/' . $this->_project_name); $this->_link_file('config', 'midgard_auth_types.xml', '/var/lib/' . $this->_project_name . '/share'); $this->_link_file('config', 'MidgardObjects.xml', '/var/lib/' . $this->_project_name . '/share'); $this->_check_dir('/var/lib/' . $this->_project_name . '/share/views'); $this->_check_dir('/var/lib/' . $this->_project_name . '/rcs'); // Create a config file $config = new midgard_config(); $config->dbtype = 'SQLite'; $config->database = $this->_project_name; $config->dbdir = '/var/lib/' . $this->_project_name; $config->blobdir = '/var/lib/' . $this->_project_name . '/blobs'; $config->sharedir = '/var/lib/' . $this->_project_name . '/share'; $config->vardir = '/var/lib/' . $this->_project_name; $config->cachedir = '/var/cache/' . $this->_project_name; $config->logfilename = '/var/log/' . $this->_project_name . '/midgard.log'; $config->loglevel = 'debug'; if (!$config->save_file($this->_project_name, false)) { $this->fail("Failed to save " . $config_file); } if (!chown($config_file, $this->_user)) { $this->fail("Failed to set permissions to " . $this->_user . ' on ' . $config_file); } $this->output("Configuration file " . $config_file . " created."); return $config; }
private function _create_config($config_name) { $project_basedir = $this->_get_basedir(); $openpsa_basedir = realpath($project_basedir . '/vendor/openpsa/midcom/'); $project_name = basename($project_basedir); self::_prepare_dir('config'); self::_prepare_dir('config/share'); self::_prepare_dir('config/share/views'); self::_prepare_dir('config/share/schema'); self::_prepare_dir('var'); self::_prepare_dir('var/cache'); self::_prepare_dir('var/rcs'); self::_prepare_dir('var/blobs'); self::_prepare_dir('var/log'); self::_link($openpsa_basedir . '/config/midgard_auth_types.xml', $project_basedir . '/config/share/midgard_auth_types.xml', $this->_io); self::_link($openpsa_basedir . '/config/MidgardObjects.xml', $project_basedir . '/config/share/MidgardObjects.xml', $this->_io); // Create a config file $config = new \midgard_config(); $config->dbtype = 'MySQL'; $config->dbuser = $this->_io->ask('<question>DB username:</question> [<comment>' . $project_name . '</comment>] ', $project_name); $config->dbpass = $this->_io->askAndHideAnswer('<question>DB password:</question> '); $config->database = $this->_io->ask('<question>DB name:</question> [<comment>' . $project_name . '</comment>] ', $project_name); $config->blobdir = $project_basedir . '/var/blobs'; $config->sharedir = $project_basedir . '/config/share'; $config->vardir = $project_basedir . '/var'; $config->cachedir = $project_basedir . '/var/cache'; $config->logfilename = $project_basedir . '/var/log/midgard.log'; $config->loglevel = 'warn'; $target_path = getenv('HOME') . '/.midgard2/conf.d/' . $project_name; if (!$config->save_file($project_name, true)) { throw new \Exception("Failed to save config file " . $target_path); } $this->_io->write("Configuration file <info>" . $target_path . "</info> created."); self::_link($target_path, $project_basedir . '/config/midgard2.ini', $this->_io); return $config; }
} if (!extension_loaded('midgard2')) { die("Midgard2 is not installed in your PHP environment.\n"); } if (!class_exists('midgardmvc_core_node')) { die("Midgard MVC or its schemas are not installed in your Midgard environment.\n"); } // Create a config file $config = new midgard_config(); $config->dbtype = 'SQLite'; $config->database = $argv[1]; $config->tablecreate = true; $config->tableupdate = true; $config->loglevel = 'warning'; // Save it to ~/.midgard2 $config->save_file($argv[1], true); echo "Configuration file ~/.midgard2/conf.d/{$argv[1]} created.\n"; // Open a DB connection with the config $midgard = midgard_connection::get_instance(); if (!$midgard->open_config($config)) { die("Failed to open Midgard database connection to {$argv[1]}: " . $midgard->get_error_string() . "\n"); } // Create storage midgard_storage::create_base_storage(); echo "Database initialized, preparing storage for MgdSchema classes:\n"; $re = new ReflectionExtension('midgard2'); $classes = $re->getClasses(); foreach ($classes as $refclass) { $parent_class = $refclass->getParentClass(); if (!$parent_class) { continue;