路由配置文件独立 不需要extra_config_file配置 改进App类

This commit is contained in:
thinkphp
2016-08-03 14:34:08 +08:00
parent 5a9b606f4b
commit e71c3630cd
3 changed files with 6 additions and 10 deletions

View File

@@ -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']);

View File

@@ -6,7 +6,7 @@
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: yunwuxin <448901948@qq.com>
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
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('<info>Succeed!</info>');
}