Example #1
0
 public function createFile($name)
 {
     $this->checkExisting($name);
     $this->checkName($name);
     $this->checkPermission();
     $timestamp = date('YmdHis', time());
     $code = new \yentu\CodeWriter();
     $code->add('');
     $code->add('begin()');
     $code->add('');
     $code->add('->end();');
     $path = Yentu::getPath("migrations/{$timestamp}_{$name}.php");
     file_put_contents($path, $code);
     \clearice\ClearIce::output("Added {$path} for new migration.\n");
 }
Example #2
0
 public function createConfigFile($params)
 {
     $params = \yentu\Parameters::wrap($params, ['port', 'file', 'host', 'dbname', 'user', 'password']);
     mkdir(Yentu::getPath(''));
     mkdir(Yentu::getPath('config'));
     mkdir(Yentu::getPath('migrations'));
     $configFile = new \yentu\CodeWriter();
     $configFile->add('return [');
     $configFile->addIndent();
     $configFile->add("'db' => [");
     $configFile->addIndent();
     $configFile->add("'driver' => '{$params['driver']}',");
     $configFile->add("'host' => '{$params['host']}',");
     $configFile->add("'port' => '{$params['port']}',");
     $configFile->add("'dbname' => '{$params['dbname']}',");
     $configFile->add("'user' => '{$params['user']}',");
     $configFile->add("'password' => '{$params['password']}',");
     $configFile->add("'file' => '{$params['file']}',");
     $configFile->decreaseIndent();
     $configFile->add(']');
     $configFile->decreaseIndent();
     $configFile->add('];');
     file_put_contents(Yentu::getPath("config/default.conf.php"), $configFile);
 }