@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | $this->basePath = $this->app->getBasePath(); |
| 41 | 41 | $dir = $input->getArgument('dir') ?: ''; |
| 42 | 42 | |
| 43 | - $list = include $this->basePath . 'build.php'; |
|
| 43 | + $list = include $this->basePath.'build.php'; |
|
| 44 | 44 | |
| 45 | 45 | if (empty($list)) { |
| 46 | 46 | $output->writeln("Build file Is Empty"); |
@@ -61,13 +61,13 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | protected function buildApp(string $dir, array $list = []): void |
| 63 | 63 | { |
| 64 | - if (!is_dir($this->basePath . $dir)) { |
|
| 64 | + if (!is_dir($this->basePath.$dir)) { |
|
| 65 | 65 | // 创建应用目录 |
| 66 | - mkdir($this->basePath . $dir); |
|
| 66 | + mkdir($this->basePath.$dir); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - $appPath = $this->basePath . ($dir ? $dir . DIRECTORY_SEPARATOR : ''); |
|
| 70 | - $namespace = 'app' . ($dir ? '\\' . $dir : ''); |
|
| 69 | + $appPath = $this->basePath.($dir ? $dir.DIRECTORY_SEPARATOR : ''); |
|
| 70 | + $namespace = 'app'.($dir ? '\\'.$dir : ''); |
|
| 71 | 71 | |
| 72 | 72 | // 创建配置文件和公共文件 |
| 73 | 73 | $this->buildCommon($dir); |
@@ -78,41 +78,41 @@ discard block |
||
| 78 | 78 | if ('__dir__' == $path) { |
| 79 | 79 | // 生成子目录 |
| 80 | 80 | foreach ($file as $dir) { |
| 81 | - $this->checkDirBuild($appPath . $dir); |
|
| 81 | + $this->checkDirBuild($appPath.$dir); |
|
| 82 | 82 | } |
| 83 | 83 | } elseif ('__file__' == $path) { |
| 84 | 84 | // 生成(空白)文件 |
| 85 | 85 | foreach ($file as $name) { |
| 86 | - if (!is_file($appPath . $name)) { |
|
| 87 | - file_put_contents($appPath . $name, 'php' == pathinfo($name, PATHINFO_EXTENSION) ? '<?php' . PHP_EOL : ''); |
|
| 86 | + if (!is_file($appPath.$name)) { |
|
| 87 | + file_put_contents($appPath.$name, 'php' == pathinfo($name, PATHINFO_EXTENSION) ? '<?php'.PHP_EOL : ''); |
|
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | } else { |
| 91 | 91 | // 生成相关MVC文件 |
| 92 | 92 | foreach ($file as $val) { |
| 93 | 93 | $val = trim($val); |
| 94 | - $filename = $appPath . $path . DIRECTORY_SEPARATOR . $val . '.php'; |
|
| 95 | - $space = $namespace . '\\' . $path; |
|
| 94 | + $filename = $appPath.$path.DIRECTORY_SEPARATOR.$val.'.php'; |
|
| 95 | + $space = $namespace.'\\'.$path; |
|
| 96 | 96 | $class = $val; |
| 97 | 97 | switch ($path) { |
| 98 | 98 | case 'controller': // 控制器 |
| 99 | 99 | if ($this->app->config->get('route.controller_suffix')) { |
| 100 | - $filename = $appPath . $path . DIRECTORY_SEPARATOR . $val . 'Controller.php'; |
|
| 101 | - $class = $val . 'Controller'; |
|
| 100 | + $filename = $appPath.$path.DIRECTORY_SEPARATOR.$val.'Controller.php'; |
|
| 101 | + $class = $val.'Controller'; |
|
| 102 | 102 | } |
| 103 | - $content = "<?php" . PHP_EOL . "namespace {$space};" . PHP_EOL . PHP_EOL . "class {$class}" . PHP_EOL . "{" . PHP_EOL . PHP_EOL . "}"; |
|
| 103 | + $content = "<?php".PHP_EOL."namespace {$space};".PHP_EOL.PHP_EOL."class {$class}".PHP_EOL."{".PHP_EOL.PHP_EOL."}"; |
|
| 104 | 104 | break; |
| 105 | 105 | case 'model': // 模型 |
| 106 | - $content = "<?php" . PHP_EOL . "namespace {$space};" . PHP_EOL . PHP_EOL . "use think\Model;" . PHP_EOL . PHP_EOL . "class {$class} extends Model" . PHP_EOL . "{" . PHP_EOL . PHP_EOL . "}"; |
|
| 106 | + $content = "<?php".PHP_EOL."namespace {$space};".PHP_EOL.PHP_EOL."use think\Model;".PHP_EOL.PHP_EOL."class {$class} extends Model".PHP_EOL."{".PHP_EOL.PHP_EOL."}"; |
|
| 107 | 107 | break; |
| 108 | 108 | case 'view': // 视图 |
| 109 | - $filename = $appPath . $path . DIRECTORY_SEPARATOR . $val . '.html'; |
|
| 109 | + $filename = $appPath.$path.DIRECTORY_SEPARATOR.$val.'.html'; |
|
| 110 | 110 | $this->checkDirBuild(dirname($filename)); |
| 111 | 111 | $content = ''; |
| 112 | 112 | break; |
| 113 | 113 | default: |
| 114 | 114 | // 其他文件 |
| 115 | - $content = "<?php" . PHP_EOL . "namespace {$space};" . PHP_EOL . PHP_EOL . "class {$class}" . PHP_EOL . "{" . PHP_EOL . PHP_EOL . "}"; |
|
| 115 | + $content = "<?php".PHP_EOL."namespace {$space};".PHP_EOL.PHP_EOL."class {$class}".PHP_EOL."{".PHP_EOL.PHP_EOL."}"; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | if (!is_file($filename)) { |
@@ -133,10 +133,10 @@ discard block |
||
| 133 | 133 | protected function buildHello(string $dir, string $namespace): void |
| 134 | 134 | { |
| 135 | 135 | $suffix = $this->app->config->get('route.controller_suffix') ? 'Controller' : ''; |
| 136 | - $filename = $this->basePath . ($dir ? $dir . DIRECTORY_SEPARATOR : '') . 'controller' . DIRECTORY_SEPARATOR . 'Index' . $suffix . '.php'; |
|
| 136 | + $filename = $this->basePath.($dir ? $dir.DIRECTORY_SEPARATOR : '').'controller'.DIRECTORY_SEPARATOR.'Index'.$suffix.'.php'; |
|
| 137 | 137 | |
| 138 | 138 | if (!is_file($filename)) { |
| 139 | - $content = file_get_contents($this->app->getThinkPath() . 'tpl' . DIRECTORY_SEPARATOR . 'default_index.tpl'); |
|
| 139 | + $content = file_get_contents($this->app->getThinkPath().'tpl'.DIRECTORY_SEPARATOR.'default_index.tpl'); |
|
| 140 | 140 | $content = str_replace(['{%name%}', '{%app%}', '{%layer%}', '{%suffix%}'], [$dir, $namespace, 'controller', $suffix], $content); |
| 141 | 141 | $this->checkDirBuild(dirname($filename)); |
| 142 | 142 | |
@@ -152,15 +152,15 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | protected function buildCommon(string $dir): void |
| 154 | 154 | { |
| 155 | - $appPath = $this->basePath . ($dir ? $dir . DIRECTORY_SEPARATOR : ''); |
|
| 155 | + $appPath = $this->basePath.($dir ? $dir.DIRECTORY_SEPARATOR : ''); |
|
| 156 | 156 | |
| 157 | - if (!is_file($appPath . 'common.php')) { |
|
| 158 | - file_put_contents($appPath . 'common.php', "<?php" . PHP_EOL . "// 这是系统自动生成的公共文件" . PHP_EOL); |
|
| 157 | + if (!is_file($appPath.'common.php')) { |
|
| 158 | + file_put_contents($appPath.'common.php', "<?php".PHP_EOL."// 这是系统自动生成的公共文件".PHP_EOL); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | foreach (['event', 'middleware', 'provider'] as $name) { |
| 162 | - if (!is_file($appPath . $name . '.php')) { |
|
| 163 | - file_put_contents($appPath . $name . '.php', "<?php" . PHP_EOL . "// 这是系统自动生成的{$name}定义文件" . PHP_EOL . "return [" . PHP_EOL . PHP_EOL . "];" . PHP_EOL); |
|
| 162 | + if (!is_file($appPath.$name.'.php')) { |
|
| 163 | + file_put_contents($appPath.$name.'.php', "<?php".PHP_EOL."// 这是系统自动生成的{$name}定义文件".PHP_EOL."return [".PHP_EOL.PHP_EOL."];".PHP_EOL); |
|
| 164 | 164 | } |
| 165 | 165 | } |
| 166 | 166 | } |