From 836a43ed0aa7e86e5135e2e542c918a9d4fd9b4f Mon Sep 17 00:00:00 2001 From: topnuomi <1130395124@qq.com> Date: Fri, 21 Jun 2019 15:13:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=BA=E5=88=B6=E5=9C=A8=E5=85=A5=E5=8F=A3?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E8=B0=83=E7=94=A8Framework::appPath()?= =?UTF-8?q?=E6=8C=87=E5=AE=9A=E5=BA=94=E7=94=A8=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- framework/Framework.php | 47 +++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/framework/Framework.php b/framework/Framework.php index 9aa4e8b..71e277a 100644 --- a/framework/Framework.php +++ b/framework/Framework.php @@ -22,7 +22,7 @@ class Framework private static $defaultModule = 'home'; /** - * 执行 + * 框架入口 * @param string $callable */ public static function startApp($callable = '') @@ -37,13 +37,32 @@ class Framework date_default_timezone_set('PRC'); self::debug(); - self::appPath(); - self::appNameSpace(); - self::resourcePath(); - self::frameworkPath(); + // 强制在入口文件指定应用目录 + if (defined('APP_PATH')) { + // self::appPath(); + self::appNameSpace(); + self::resourcePath(); + self::frameworkPath(); - require 'library/App.php'; - App::start(self::$type, self::$defaultModule); + require 'library/App.php'; + App::start(self::$type, self::$defaultModule); + } else { + echo '请使用Framework::appPath()指定应用目录'; + } + } + + /** + * 应用目录 + * @param string $path + */ + public static function appPath($path = '') + { + if (!defined('APP_PATH')) { + if (!$path) { + $path = './application/'; + } + define('APP_PATH', $path); + } } /** @@ -71,20 +90,6 @@ class Framework } } - /** - * 应用目录 - * @param string $path - */ - public static function appPath($path = '') - { - if (!defined('APP_PATH')) { - if (!$path) { - $path = './application/'; - } - define('APP_PATH', $path); - } - } - public static function appNameSpace($namespace = '') { if (!defined('APP_NS')) {