think\Build::run PHP Method

run() public static method

根据传入的build资料创建目录和文件
public static run ( array $build = [], string $namespace = 'app', boolean $suffix = false ) : void
$build array build列表
$namespace string 应用类库命名空间
$suffix boolean 类库后缀
return void
    public static function run(array $build = [], $namespace = 'app', $suffix = false)
    {
        // 锁定
        $lockfile = APP_PATH . 'build.lock';
        if (is_writable($lockfile)) {
            return;
        } elseif (!touch($lockfile)) {
            throw new Exception('应用目录[' . APP_PATH . ']不可写,目录无法自动生成!<BR>请手动生成项目目录~', 10006);
        }
        foreach ($build as $module => $list) {
            if ('__dir__' == $module) {
                // 创建目录列表
                self::buildDir($list);
            } elseif ('__file__' == $module) {
                // 创建文件列表
                self::buildFile($list);
            } else {
                // 创建模块
                self::module($module, $list, $namespace, $suffix);
            }
        }
        // 解除锁定
        unlink($lockfile);
    }

Usage Example

Ejemplo n.º 1
0
 protected function execute(Input $input, Output $output)
 {
     if ($input->hasOption('config')) {
         $build = (include $input->getOption('config'));
     } else {
         $build = (include APP_PATH . 'build.php');
     }
     if (empty($build)) {
         $output->writeln("Build Config Is Empty");
         return;
     }
     \think\Build::run($build);
     $output->writeln("Successed");
 }
All Usage Examples Of think\Build::run