Skip to content

Commit

Permalink
优化项目初始化
Browse files Browse the repository at this point in the history
  • Loading branch information
wushuiyong committed Nov 7, 2015
1 parent 3f53683 commit 336e28b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions console/RunController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,36 @@ class RunController extends Controller {
* @throws yii\console\Exception
*/
public function actionSetup() {
$this->runAction('create-dir', ['interactive' => $this->interactive]);
$this->runAction('set-writable', ['interactive' => $this->interactive]);
$this->runAction('set-executable', ['interactive' => $this->interactive]);
\Yii::$app->runAction('migrate/up', ['interactive' => $this->interactive]);
}

public function actionCreateDir() {
$mkdirPaths = [
yii::$app->params['log.dir']
];
$this->mkdir($mkdirPaths);
}

public function actionSetWritable() {
$this->writablePaths[] = yii::$app->params['log.dir'];
$this->setWritable($this->writablePaths);
}

public function actionSetExecutable() {
$this->setExecutable($this->executablePaths);
}

public function mkdir($paths) {
foreach ($paths as $path) {
$path = Yii::getAlias($path);
Console::output("mkdiring dir: {$path}");
@mkdir($path, 0755);
}
}

public function setWritable($paths) {
foreach ($paths as $writable) {
$writable = Yii::getAlias($writable);
Expand All @@ -55,4 +72,5 @@ public function setExecutable($paths) {
}
}


}

0 comments on commit 336e28b

Please sign in to comment.