From 51452be436f427c7a4f4dacfcf8b4a4fe88e56ca Mon Sep 17 00:00:00 2001 From: thinkphp Date: Wed, 31 Aug 2016 19:11:31 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=8F=82=E6=95=B0=E8=AF=BB?= =?UTF-8?q?=E5=8F=96=E7=9A=84=E6=97=B6=E5=80=99=E5=8F=96=E6=B6=88=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E5=8F=98=E9=87=8F=E5=88=A4=E6=96=AD=20=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E8=AF=BB=E5=8F=96=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/App.php | 3 ++- library/think/Config.php | 23 ++--------------------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/library/think/App.php b/library/think/App.php index a9236f6f..b781d75b 100644 --- a/library/think/App.php +++ b/library/think/App.php @@ -12,6 +12,7 @@ namespace think; use think\Config; +use think\Env; use think\Exception; use think\exception\HttpException; use think\exception\HttpResponseException; @@ -371,7 +372,7 @@ class App self::$suffix = $config['class_suffix']; // 应用调试模式 - self::$debug = Config::get('app_debug'); + self::$debug = Env::get('app_debug', Config::get('app_debug')); if (!self::$debug) { ini_set('display_errors', 'Off'); } elseif (!IS_CLI) { diff --git a/library/think/Config.php b/library/think/Config.php index 7256e0ed..5ab032fd 100644 --- a/library/think/Config.php +++ b/library/think/Config.php @@ -81,20 +81,10 @@ class Config $range = $range ?: self::$range; if (!strpos($name, '.')) { - // 判断环境变量 - $result = getenv(ENV_PREFIX . strtoupper($name)); - if (false !== $result) { - return $result; - } return isset(self::$config[$range][strtolower($name)]); } else { // 二维数组设置和获取支持 - $name = explode('.', $name); - $result = getenv(ENV_PREFIX . strtoupper($name[0] . '_' . $name[1])); - // 判断环境变量 - if (false !== $result) { - return $result; - } + $name = explode('.', $name); return isset(self::$config[$range][strtolower($name[0])][$name[1]]); } } @@ -114,20 +104,11 @@ class Config } if (!strpos($name, '.')) { - $result = getenv(ENV_PREFIX . strtoupper($name)); - if (false !== $result) { - return $result; - } $name = strtolower($name); return isset(self::$config[$range][$name]) ? self::$config[$range][$name] : null; } else { // 二维数组设置和获取支持 - $name = explode('.', $name); - $result = getenv(ENV_PREFIX . strtoupper($name[0] . '_' . $name[1])); - // 判断环境变量 - if (false !== $result) { - return $result; - } + $name = explode('.', $name); $name[0] = strtolower($name[0]); return isset(self::$config[$range][$name[0]][$name[1]]) ? self::$config[$range][$name[0]][$name[1]] : null; }