diff --git a/library/think/Build.php b/library/think/Build.php index 5b7306cf..e0982561 100644 --- a/library/think/Build.php +++ b/library/think/Build.php @@ -12,7 +12,8 @@ namespace think; class Build { - public static function run($build) + // 根据传入的build资料创建目录和文件 + public static function run($build = []) { // 锁定 $lockfile = APP_PATH . 'build.lock'; @@ -30,7 +31,7 @@ class Build self::buildFile($list); } else { // 创建模块 - self::buildModule($module, $list); + self::module($module, $list); } } // 解除锁定 @@ -63,7 +64,7 @@ class Build } // 创建模块 - protected static function buildModule($module, $list) + public static function module($module = '', $list = []) { $module = APP_MULTI_MODULE ? $module : ''; if (!is_dir(APP_PATH . $module)) { @@ -76,6 +77,13 @@ class Build // 创建模块的默认页面 self::buildHello($module); } + if (empty($list)) { + // 创建默认的模块目录和文件 + $list = [ + '__file__' => ['config.php', 'common.php'], + '__dir__' => ['controller', 'model', 'view'], + ]; + } // 创建子目录和文件 foreach ($list as $path => $file) { $modulePath = APP_PATH . $module . DS; @@ -101,13 +109,13 @@ class Build $namespace = APP_NAMESPACE . '\\' . ($module ? $module . '\\' : '') . $path; $class = $val . (CLASS_APPEND_SUFFIX ? ucfirst($path) : ''); switch ($path) { - case CONTROLLER_LAYER: // 控制器 + case CONTROLLER_LAYER: // 控制器 $content = "