From 62db503259e9c93b0c72ae26776d4d6aaba6fd34 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Tue, 23 Aug 2016 12:20:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=85=A5=E5=8F=A3=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E8=87=AA=E5=8A=A8=E7=BB=91=E5=AE=9A=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- convention.php | 2 ++ library/think/App.php | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/convention.php b/convention.php index faf7571b..6a841a30 100644 --- a/convention.php +++ b/convention.php @@ -15,6 +15,8 @@ return [ 'app_status' => '', // 是否支持多模块 'app_multi_module' => true, + // 入口自动绑定模块 + 'auto_bind_module' => false, // 注册的根命名空间 'root_namespace' => [], // 扩展配置文件 diff --git a/library/think/App.php b/library/think/App.php index 3cecba90..a7890bb4 100644 --- a/library/think/App.php +++ b/library/think/App.php @@ -79,6 +79,17 @@ class App is_null($request) && $request = Request::instance(); $config = self::initCommon(); + if (defined('BIND_MODULE')) { + // 模块/控制器绑定 + Route::bind(BIND_MODULE); + } elseif ($config['auto_bind_module']) { + // 入口自动绑定 + $name = pathinfo($request->baseFile(), PATHINFO_FILENAME); + if ($name && 'index' != $name && is_dir(APP_PATH . $name)) { + Route::bind($name); + } + } + $request->filter($config['default_filter']); try { @@ -374,7 +385,7 @@ class App } } - // 应用命名空间 + // 注册应用命名空间 self::$namespace = $config['app_namespace']; Loader::addNamespace($config['app_namespace'], APP_PATH); if (!empty($config['root_namespace'])) {