@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | // +---------------------------------------------------------------------- |
| 9 | 9 | // | Author: liu21st <[email protected]> |
| 10 | 10 | // +---------------------------------------------------------------------- |
| 11 | -declare (strict_types = 1); |
|
| 11 | +declare(strict_types=1); |
|
| 12 | 12 | |
| 13 | 13 | namespace think\log\driver; |
| 14 | 14 | |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | if ($this->config['json']) { |
| 87 | 87 | $info[] = json_encode(['time' => $time, 'type' => $type, 'msg' => $msg], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); |
| 88 | 88 | } else { |
| 89 | - $info[$type][] = '[' . $time . '][' . $type . '] ' . $msg; |
|
| 89 | + $info[$type][] = '['.$time.']['.$type.'] '.$msg; |
|
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | $info[$type] = is_array($msg) ? implode(PHP_EOL, $msg) : $msg; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - $message = implode(PHP_EOL, $info) . PHP_EOL; |
|
| 128 | + $message = implode(PHP_EOL, $info).PHP_EOL; |
|
| 129 | 129 | |
| 130 | 130 | return error_log($message, 3, $destination); |
| 131 | 131 | } |
@@ -138,13 +138,13 @@ discard block |
||
| 138 | 138 | protected function getMasterLogFile(): string |
| 139 | 139 | { |
| 140 | 140 | if (empty($this->config['path'])) { |
| 141 | - $this->config['path'] = $this->app->getRuntimePath() . 'log' . DIRECTORY_SEPARATOR; |
|
| 141 | + $this->config['path'] = $this->app->getRuntimePath().'log'.DIRECTORY_SEPARATOR; |
|
| 142 | 142 | } elseif (substr($this->config['path'], -1) != DIRECTORY_SEPARATOR) { |
| 143 | 143 | $this->config['path'] .= DIRECTORY_SEPARATOR; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | if ($this->config['max_files']) { |
| 147 | - $files = glob($this->config['path'] . '*.log'); |
|
| 147 | + $files = glob($this->config['path'].'*.log'); |
|
| 148 | 148 | |
| 149 | 149 | try { |
| 150 | 150 | if (count($files) > $this->config['max_files']) { |
@@ -158,17 +158,17 @@ discard block |
||
| 158 | 158 | if ($this->config['single']) { |
| 159 | 159 | $name = is_string($this->config['single']) ? $this->config['single'] : 'single'; |
| 160 | 160 | $cli = $this->isCli ? '_cli' : ''; |
| 161 | - $destination = $this->config['path'] . $name . $cli . '.log'; |
|
| 161 | + $destination = $this->config['path'].$name.$cli.'.log'; |
|
| 162 | 162 | } else { |
| 163 | 163 | $cli = $this->isCli ? '_cli' : ''; |
| 164 | 164 | |
| 165 | 165 | if ($this->config['max_files']) { |
| 166 | - $filename = date('Ymd') . $cli . '.log'; |
|
| 166 | + $filename = date('Ymd').$cli.'.log'; |
|
| 167 | 167 | } else { |
| 168 | - $filename = date('Ym') . DIRECTORY_SEPARATOR . date('d') . $cli . '.log'; |
|
| 168 | + $filename = date('Ym').DIRECTORY_SEPARATOR.date('d').$cli.'.log'; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - $destination = $this->config['path'] . $filename; |
|
| 171 | + $destination = $this->config['path'].$filename; |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | return $destination; |
@@ -188,14 +188,14 @@ discard block |
||
| 188 | 188 | if ($this->config['single']) { |
| 189 | 189 | $name = is_string($this->config['single']) ? $this->config['single'] : 'single'; |
| 190 | 190 | |
| 191 | - $name .= '_' . $type; |
|
| 191 | + $name .= '_'.$type; |
|
| 192 | 192 | } elseif ($this->config['max_files']) { |
| 193 | - $name = date('Ymd') . '_' . $type . $cli; |
|
| 193 | + $name = date('Ymd').'_'.$type.$cli; |
|
| 194 | 194 | } else { |
| 195 | - $name = date('d') . '_' . $type . $cli; |
|
| 195 | + $name = date('d').'_'.$type.$cli; |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - return $path . DIRECTORY_SEPARATOR . $name . '.log'; |
|
| 198 | + return $path.DIRECTORY_SEPARATOR.$name.'.log'; |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | { |
| 209 | 209 | if (is_file($destination) && floor($this->config['file_size']) <= filesize($destination)) { |
| 210 | 210 | try { |
| 211 | - rename($destination, dirname($destination) . DIRECTORY_SEPARATOR . time() . '-' . basename($destination)); |
|
| 211 | + rename($destination, dirname($destination).DIRECTORY_SEPARATOR.time().'-'.basename($destination)); |
|
| 212 | 212 | } catch (\Exception $e) { |
| 213 | 213 | // |
| 214 | 214 | } |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | // +---------------------------------------------------------------------- |
| 9 | 9 | // | Author: liu21st <[email protected]> |
| 10 | 10 | // +---------------------------------------------------------------------- |
| 11 | -declare (strict_types = 1); |
|
| 11 | +declare(strict_types=1); |
|
| 12 | 12 | |
| 13 | 13 | namespace think; |
| 14 | 14 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | public function __construct(App $app) |
| 57 | 57 | { |
| 58 | 58 | $this->app = $app; |
| 59 | - $this->multi = is_dir($this->app->getBasePath() . 'controller') ? false : true; |
|
| 59 | + $this->multi = is_dir($this->app->getBasePath().'controller') ? false : true; |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -172,8 +172,8 @@ discard block |
||
| 172 | 172 | $this->initialize(); |
| 173 | 173 | |
| 174 | 174 | // 加载全局中间件 |
| 175 | - if (is_file($this->app->getBasePath() . 'middleware.php')) { |
|
| 176 | - $this->app->middleware->import(include $this->app->getBasePath() . 'middleware.php'); |
|
| 175 | + if (is_file($this->app->getBasePath().'middleware.php')) { |
|
| 176 | + $this->app->middleware->import(include $this->app->getBasePath().'middleware.php'); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | if ($this->multi) { |
@@ -186,9 +186,9 @@ discard block |
||
| 186 | 186 | // 监听HttpRun |
| 187 | 187 | $this->app->event->trigger('HttpRun'); |
| 188 | 188 | |
| 189 | - $this->app->log->info($request->ip() . ' ' . $request->method() . ' ' . $request->host() . $request->url()); |
|
| 189 | + $this->app->log->info($request->ip().' '.$request->method().' '.$request->host().$request->url()); |
|
| 190 | 190 | |
| 191 | - $withRoute = $this->app->config->get('app.with_route', true) ? function () { |
|
| 191 | + $withRoute = $this->app->config->get('app.with_route', true) ? function() { |
|
| 192 | 192 | $this->loadRoutes(); |
| 193 | 193 | } : null; |
| 194 | 194 | |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | { |
| 205 | 205 | // 加载路由定义 |
| 206 | 206 | if (is_dir($this->getRoutePath())) { |
| 207 | - $files = glob($this->getRoutePath() . '*.php'); |
|
| 207 | + $files = glob($this->getRoutePath().'*.php'); |
|
| 208 | 208 | foreach ($files as $file) { |
| 209 | 209 | include $file; |
| 210 | 210 | } |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | */ |
| 221 | 221 | protected function getRoutePath(): string |
| 222 | 222 | { |
| 223 | - return $this->app->getRootPath() . 'route' . DIRECTORY_SEPARATOR . ($this->isMulti() ? $this->getName() . DIRECTORY_SEPARATOR : ''); |
|
| 223 | + return $this->app->getRootPath().'route'.DIRECTORY_SEPARATOR.($this->isMulti() ? $this->getName().DIRECTORY_SEPARATOR : ''); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | /** |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | $appName = $map[$name]; |
| 306 | 306 | } |
| 307 | 307 | } elseif ($name && (false !== array_search($name, $map) || in_array($name, $deny))) { |
| 308 | - throw new HttpException(404, 'app not exists:' . $name); |
|
| 308 | + throw new HttpException(404, 'app not exists:'.$name); |
|
| 309 | 309 | } elseif ($name && isset($map['*'])) { |
| 310 | 310 | $appName = $map['*']; |
| 311 | 311 | } else { |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | if ($name) { |
| 316 | - $this->app->request->setRoot('/' . $name); |
|
| 316 | + $this->app->request->setRoot('/'.$name); |
|
| 317 | 317 | $this->app->request->setPathinfo(strpos($path, '/') ? ltrim(strstr($path, '/'), '/') : ''); |
| 318 | 318 | } |
| 319 | 319 | } |
@@ -333,41 +333,41 @@ discard block |
||
| 333 | 333 | { |
| 334 | 334 | $this->name = $appName; |
| 335 | 335 | $this->app->request->setApp($appName); |
| 336 | - $this->app->setAppPath($this->path ?: $this->app->getBasePath() . $appName . DIRECTORY_SEPARATOR); |
|
| 337 | - $this->app->setRuntimePath($this->app->getRootPath() . 'runtime' . DIRECTORY_SEPARATOR . $appName . DIRECTORY_SEPARATOR); |
|
| 336 | + $this->app->setAppPath($this->path ?: $this->app->getBasePath().$appName.DIRECTORY_SEPARATOR); |
|
| 337 | + $this->app->setRuntimePath($this->app->getRootPath().'runtime'.DIRECTORY_SEPARATOR.$appName.DIRECTORY_SEPARATOR); |
|
| 338 | 338 | |
| 339 | 339 | //加载app文件 |
| 340 | 340 | if (is_dir($this->app->getAppPath())) { |
| 341 | 341 | $appPath = $this->app->getAppPath(); |
| 342 | 342 | |
| 343 | - if (is_file($appPath . 'common.php')) { |
|
| 344 | - include_once $appPath . 'common.php'; |
|
| 343 | + if (is_file($appPath.'common.php')) { |
|
| 344 | + include_once $appPath.'common.php'; |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | $configPath = $this->app->getConfigPath(); |
| 348 | 348 | |
| 349 | 349 | $files = []; |
| 350 | 350 | |
| 351 | - if (is_dir($configPath . $appName)) { |
|
| 352 | - $files = array_merge($files, glob($configPath . $appName . DIRECTORY_SEPARATOR . '*' . $this->app->getConfigExt())); |
|
| 353 | - } elseif (is_dir($appPath . 'config')) { |
|
| 354 | - $files = array_merge($files, glob($appPath . 'config' . DIRECTORY_SEPARATOR . '*' . $this->app->getConfigExt())); |
|
| 351 | + if (is_dir($configPath.$appName)) { |
|
| 352 | + $files = array_merge($files, glob($configPath.$appName.DIRECTORY_SEPARATOR.'*'.$this->app->getConfigExt())); |
|
| 353 | + } elseif (is_dir($appPath.'config')) { |
|
| 354 | + $files = array_merge($files, glob($appPath.'config'.DIRECTORY_SEPARATOR.'*'.$this->app->getConfigExt())); |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | foreach ($files as $file) { |
| 358 | 358 | $this->app->config->load($file, pathinfo($file, PATHINFO_FILENAME)); |
| 359 | 359 | } |
| 360 | 360 | |
| 361 | - if (is_file($appPath . 'event.php')) { |
|
| 362 | - $this->app->loadEvent(include $appPath . 'event.php'); |
|
| 361 | + if (is_file($appPath.'event.php')) { |
|
| 362 | + $this->app->loadEvent(include $appPath.'event.php'); |
|
| 363 | 363 | } |
| 364 | 364 | |
| 365 | - if (is_file($appPath . 'middleware.php')) { |
|
| 366 | - $this->app->middleware->import(include $appPath . 'middleware.php'); |
|
| 365 | + if (is_file($appPath.'middleware.php')) { |
|
| 366 | + $this->app->middleware->import(include $appPath.'middleware.php'); |
|
| 367 | 367 | } |
| 368 | 368 | |
| 369 | - if (is_file($appPath . 'provider.php')) { |
|
| 370 | - $this->app->bind(include $appPath . 'provider.php'); |
|
| 369 | + if (is_file($appPath.'provider.php')) { |
|
| 370 | + $this->app->bind(include $appPath.'provider.php'); |
|
| 371 | 371 | } |
| 372 | 372 | } |
| 373 | 373 | |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | $this->app->loadLangPack($this->app->lang->defaultLangSet()); |
| 376 | 376 | |
| 377 | 377 | // 设置应用命名空间 |
| 378 | - $this->app->setNamespace($this->app->config->get('app.app_namespace') ?: 'app\\' . $appName); |
|
| 378 | + $this->app->setNamespace($this->app->config->get('app.app_namespace') ?: 'app\\'.$appName); |
|
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | /** |