From e71c3630cda82f5668c0ae8c453128d25a5918b6 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 3 Aug 2016 14:34:08 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B7=AF=E7=94=B1=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E7=8B=AC=E7=AB=8B=20=E4=B8=8D=E9=9C=80=E8=A6=81extra?= =?UTF-8?q?=5Fconfig=5Ffile=E9=85=8D=E7=BD=AE=20=E6=94=B9=E8=BF=9BApp?= =?UTF-8?q?=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- convention.php | 2 +- library/think/App.php | 10 ++++------ library/think/console/command/optimize/Route.php | 4 +--- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/convention.php b/convention.php index 1dcf80dc..d9003ca6 100644 --- a/convention.php +++ b/convention.php @@ -18,7 +18,7 @@ return [ // 注册的根命名空间 'root_namespace' => [], // 扩展配置文件 - 'extra_config_list' => ['database', 'route', 'validate'], + 'extra_config_list' => ['database', 'validate'], // 扩展函数文件 'extra_file_list' => [THINK_PATH . 'helper' . EXT], // 默认输出类型 diff --git a/library/think/App.php b/library/think/App.php index c1388b51..30350e3a 100644 --- a/library/think/App.php +++ b/library/think/App.php @@ -437,9 +437,6 @@ class App if ($config['extra_config_list']) { foreach ($config['extra_config_list'] as $name => $file) { $filename = CONF_PATH . $module . $file . CONF_EXT; - if ('route' == $module . $file && is_file(RUNTIME_PATH . 'route.php')) { - continue; - } Config::load($filename, is_string($name) ? $name : pathinfo($filename, PATHINFO_FILENAME)); } } @@ -485,10 +482,11 @@ class App if ($check) { // 开启路由 if (is_file(RUNTIME_PATH . 'route.php')) { - Route::rules(include RUNTIME_PATH . 'route.php'); - } elseif (!empty($config['route'])) { + // 读取路由缓存 + Route::rules(include RUNTIME_PATH . 'route.php' ?: []); + } elseif (is_file(CONF_PATH . 'route' . CONF_EXT)) { // 导入路由配置 - Route::import($config['route']); + Route::import(include CONF_PATH . 'route' . CONF_EXT ?: []); } // 路由检测(根据路由定义返回不同的URL调度) $result = Route::check($request, $path, $depr, $config['url_domain_deploy']); diff --git a/library/think/console/command/optimize/Route.php b/library/think/console/command/optimize/Route.php index 2860cef3..2d879b69 100644 --- a/library/think/console/command/optimize/Route.php +++ b/library/think/console/command/optimize/Route.php @@ -6,7 +6,7 @@ // +---------------------------------------------------------------------- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) // +---------------------------------------------------------------------- -// | Author: yunwuxin <448901948@qq.com> +// | Author: liu21st // +---------------------------------------------------------------------- namespace think\console\command\optimize; @@ -27,9 +27,7 @@ class Route extends Command protected function execute(Input $input, Output $output) { - file_put_contents(RUNTIME_PATH . 'route.php', $this->buildRouteCache()); - $output->writeln('Succeed!'); }