예제 #1
0
    public function actionConfig()
    {
        $configPath = \Yii::getAlias('@app/config/db-local.php');
        if (!file_exists($configPath) && $this->confirm('Write database parameters now?', true)) {
            $database = $this->prompt('Name of the **existing** database?', ['required' => true]);
            $hostname = $this->prompt('Hostname?', ['required' => true, 'default' => 'localhost']);
            $username = $this->prompt('Username?', ['required' => true, 'default' => 'root']);
            $password = $this->prompt('Password?');
            $config = <<<CONF
<?php

return [
\t'class' => 'yii\\db\\Connection',
\t'dsn' => 'mysql:host={$hostname};dbname={$database}',
\t'username' => '{$username}',
\t'password' => '{$password}',
\t'charset' => 'utf8',
];

CONF;
            if (file_put_contents($configPath, $config)) {
                \Yii::$app->set('db', require $configPath);
                $this->stdout("Wrote data to: {$configPath}" . \PHP_EOL);
                $this->actionDatabase();
            }
        }
        $configPath = \Yii::getAlias('@app/config/banks-default.php');
        if (!file_exists($configPath) && $this->confirm('Write default bank config now?', true)) {
            InstallHelper::ensureConfigFile($configPath, InstallHelper::CONF_DEFAULT);
            $this->stdout("Wrote data to: {$configPath}" . \PHP_EOL);
        }
        $configPath = \Yii::getAlias('@app/config/banks-local.php');
        if (!file_exists($configPath) && $this->confirm('Write default localized bank config now?', true)) {
            InstallHelper::ensureConfigFile($configPath, InstallHelper::CONF_LOCAL);
            $this->stdout("Wrote data to: {$configPath}" . \PHP_EOL);
        }
    }
예제 #2
0
 public function init()
 {
     InstallHelper::ensureConfigFile('banks-default.php', InstallHelper::CONF_DEFAULT);
     InstallHelper::ensureConfigFile('banks-local.php', InstallHelper::CONF_LOCAL);
     parent::init();
 }