mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 12:42:48 +08:00
取消 APP_DEBUG 常量 改为 App::$debug 属性获取 设置调试模式 改为 app_debug 配置参数 在应用配置文件中设置
This commit is contained in:
@@ -5,6 +5,8 @@ return [
|
|||||||
// | 应用设置
|
// | 应用设置
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
// 应用调试模式
|
||||||
|
'app_debug' => true,
|
||||||
// 应用模式状态
|
// 应用模式状态
|
||||||
'app_status' => '',
|
'app_status' => '',
|
||||||
// 是否支持多模块
|
// 是否支持多模块
|
||||||
|
|||||||
@@ -39,6 +39,11 @@ class App
|
|||||||
*/
|
*/
|
||||||
public static $modulePath;
|
public static $modulePath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool 应用调试模式
|
||||||
|
*/
|
||||||
|
public static $debug = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行应用程序
|
* 执行应用程序
|
||||||
* @access public
|
* @access public
|
||||||
@@ -72,7 +77,7 @@ class App
|
|||||||
$dispatch = self::route($request, $config);
|
$dispatch = self::route($request, $config);
|
||||||
}
|
}
|
||||||
// 记录路由信息
|
// 记录路由信息
|
||||||
APP_DEBUG && Log::record('[ ROUTE ] ' . var_export($dispatch, true), 'info');
|
self::$debug && Log::record('[ ROUTE ] ' . var_export($dispatch, true), 'info');
|
||||||
// 监听app_begin
|
// 监听app_begin
|
||||||
Hook::listen('app_begin', $dispatch);
|
Hook::listen('app_begin', $dispatch);
|
||||||
|
|
||||||
@@ -133,7 +138,7 @@ class App
|
|||||||
$reflect = new \ReflectionFunction($function);
|
$reflect = new \ReflectionFunction($function);
|
||||||
$args = self::bindParams($reflect, $vars);
|
$args = self::bindParams($reflect, $vars);
|
||||||
// 记录执行信息
|
// 记录执行信息
|
||||||
APP_DEBUG && Log::record('[ RUN ] ' . $reflect->getFileName() . '[ ' . var_export($vars, true) . ' ]', 'info');
|
self::$debug && Log::record('[ RUN ] ' . $reflect->getFileName() . '[ ' . var_export($vars, true) . ' ]', 'info');
|
||||||
return $reflect->invokeArgs($args);
|
return $reflect->invokeArgs($args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,7 +164,7 @@ class App
|
|||||||
}
|
}
|
||||||
$args = self::bindParams($reflect, $vars);
|
$args = self::bindParams($reflect, $vars);
|
||||||
// 记录执行信息
|
// 记录执行信息
|
||||||
APP_DEBUG && Log::record('[ RUN ] ' . $reflect->getFileName() . '[ ' . var_export($args, true) . ' ]', 'info');
|
self::$debug && Log::record('[ RUN ] ' . $reflect->getFileName() . '[ ' . var_export($args, true) . ' ]', 'info');
|
||||||
return $reflect->invokeArgs(isset($class) ? $class : null, $args);
|
return $reflect->invokeArgs(isset($class) ? $class : null, $args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -280,7 +285,7 @@ class App
|
|||||||
if (method_exists($instance, '_empty')) {
|
if (method_exists($instance, '_empty')) {
|
||||||
$method = new \ReflectionMethod($instance, '_empty');
|
$method = new \ReflectionMethod($instance, '_empty');
|
||||||
$data = $method->invokeArgs($instance, [$action, '']);
|
$data = $method->invokeArgs($instance, [$action, '']);
|
||||||
APP_DEBUG && Log::record('[ RUN ] ' . $method->getFileName(), 'info');
|
self::$debug && Log::record('[ RUN ] ' . $method->getFileName(), 'info');
|
||||||
} else {
|
} else {
|
||||||
throw new HttpException(404, 'method [ ' . (new \ReflectionClass($instance))->getName() . '->' . $action . ' ] not exists ');
|
throw new HttpException(404, 'method [ ' . (new \ReflectionClass($instance))->getName() . '->' . $action . ' ] not exists ');
|
||||||
}
|
}
|
||||||
@@ -297,6 +302,9 @@ class App
|
|||||||
// 初始化应用
|
// 初始化应用
|
||||||
self::$init = $config = self::init();
|
self::$init = $config = self::init();
|
||||||
|
|
||||||
|
// 是否调试模式
|
||||||
|
self::$debug = Config::get('app_debug');
|
||||||
|
|
||||||
// 注册根命名空间
|
// 注册根命名空间
|
||||||
if (!empty($config['root_namespace'])) {
|
if (!empty($config['root_namespace'])) {
|
||||||
Loader::addNamespace($config['root_namespace']);
|
Loader::addNamespace($config['root_namespace']);
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
namespace think;
|
namespace think;
|
||||||
|
|
||||||
|
use think\App;
|
||||||
|
|
||||||
class Cache
|
class Cache
|
||||||
{
|
{
|
||||||
protected static $instance = [];
|
protected static $instance = [];
|
||||||
@@ -42,7 +44,7 @@ class Cache
|
|||||||
$class = (!empty($options['namespace']) ? $options['namespace'] : '\\think\\cache\\driver\\') . ucwords($type);
|
$class = (!empty($options['namespace']) ? $options['namespace'] : '\\think\\cache\\driver\\') . ucwords($type);
|
||||||
|
|
||||||
// 记录初始化信息
|
// 记录初始化信息
|
||||||
APP_DEBUG && Log::record('[ CACHE ] INIT ' . $type . ':' . var_export($options, true), 'info');
|
App::$debug && Log::record('[ CACHE ] INIT ' . $type . ':' . var_export($options, true), 'info');
|
||||||
if (true === $name) {
|
if (true === $name) {
|
||||||
return new $class($options);
|
return new $class($options);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
namespace think;
|
namespace think;
|
||||||
|
|
||||||
|
use think\App;
|
||||||
|
|
||||||
class Config
|
class Config
|
||||||
{
|
{
|
||||||
// 配置参数
|
// 配置参数
|
||||||
@@ -59,7 +61,7 @@ class Config
|
|||||||
}
|
}
|
||||||
if (is_file($file)) {
|
if (is_file($file)) {
|
||||||
// 记录加载信息
|
// 记录加载信息
|
||||||
APP_DEBUG && Log::record('[ CONFIG ] ' . $file, 'info');
|
App::$debug && Log::record('[ CONFIG ] ' . $file, 'info');
|
||||||
$type = pathinfo($file, PATHINFO_EXTENSION);
|
$type = pathinfo($file, PATHINFO_EXTENSION);
|
||||||
if ('php' != $type) {
|
if ('php' != $type) {
|
||||||
return self::parse($file, $type, $name, $range);
|
return self::parse($file, $type, $name, $range);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace think;
|
namespace think;
|
||||||
|
|
||||||
|
use think\App;
|
||||||
use think\Collection;
|
use think\Collection;
|
||||||
use think\db\Query;
|
use think\db\Query;
|
||||||
|
|
||||||
@@ -68,7 +69,7 @@ class Db
|
|||||||
}
|
}
|
||||||
$class = (!empty($options['namespace']) ? $options['namespace'] : '\\think\\db\\connector\\') . ucwords($options['type']);
|
$class = (!empty($options['namespace']) ? $options['namespace'] : '\\think\\db\\connector\\') . ucwords($options['type']);
|
||||||
// 记录初始化信息
|
// 记录初始化信息
|
||||||
APP_DEBUG && Log::record('[ DB ] INIT ' . $options['type'] . ':' . var_export($options, true), 'info');
|
App::$debug && Log::record('[ DB ] INIT ' . $options['type'] . ':' . var_export($options, true), 'info');
|
||||||
if (true === $name) {
|
if (true === $name) {
|
||||||
return new $class($options);
|
return new $class($options);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace think;
|
namespace think;
|
||||||
|
|
||||||
|
use think\App;
|
||||||
use think\console\Output as ConsoleOutput;
|
use think\console\Output as ConsoleOutput;
|
||||||
use think\exception\ErrorException;
|
use think\exception\ErrorException;
|
||||||
use think\exception\Handle;
|
use think\exception\Handle;
|
||||||
@@ -29,7 +30,7 @@ class Error
|
|||||||
set_exception_handler([__CLASS__, 'appException']);
|
set_exception_handler([__CLASS__, 'appException']);
|
||||||
register_shutdown_function([__CLASS__, 'appShutdown']);
|
register_shutdown_function([__CLASS__, 'appShutdown']);
|
||||||
|
|
||||||
if (!APP_DEBUG) {
|
if (!App::$debug) {
|
||||||
ini_set('display_errors', 'Off');
|
ini_set('display_errors', 'Off');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace think;
|
namespace think;
|
||||||
|
|
||||||
|
use think\App;
|
||||||
use think\Debug;
|
use think\Debug;
|
||||||
use think\Log;
|
use think\Log;
|
||||||
|
|
||||||
@@ -100,7 +101,7 @@ class Hook
|
|||||||
if (isset(self::$tags[$tag])) {
|
if (isset(self::$tags[$tag])) {
|
||||||
foreach (self::$tags[$tag] as $name) {
|
foreach (self::$tags[$tag] as $name) {
|
||||||
|
|
||||||
if (APP_DEBUG) {
|
if (App::$debug) {
|
||||||
Debug::remark('behavior_start', 'time');
|
Debug::remark('behavior_start', 'time');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +111,7 @@ class Hook
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (APP_DEBUG) {
|
if (App::$debug) {
|
||||||
Debug::remark('behavior_end', 'time');
|
Debug::remark('behavior_end', 'time');
|
||||||
if ($name instanceof \Closure) {
|
if ($name instanceof \Closure) {
|
||||||
$name = 'Closure';
|
$name = 'Closure';
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace think;
|
namespace think;
|
||||||
|
|
||||||
|
use think\App;
|
||||||
use think\Cookie;
|
use think\Cookie;
|
||||||
use think\Log;
|
use think\Log;
|
||||||
|
|
||||||
@@ -78,7 +79,7 @@ class Lang
|
|||||||
foreach ($file as $_file) {
|
foreach ($file as $_file) {
|
||||||
if (is_file($_file)) {
|
if (is_file($_file)) {
|
||||||
// 记录加载信息
|
// 记录加载信息
|
||||||
APP_DEBUG && Log::record('[ LANG ] ' . $_file, 'info');
|
App::$debug && Log::record('[ LANG ] ' . $_file, 'info');
|
||||||
$_lang = include $_file;
|
$_lang = include $_file;
|
||||||
} else {
|
} else {
|
||||||
$_lang = [];
|
$_lang = [];
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace think;
|
namespace think;
|
||||||
|
|
||||||
|
use think\App;
|
||||||
use think\exception\HttpException;
|
use think\exception\HttpException;
|
||||||
use think\exception\ClassNotFoundException;
|
use think\exception\ClassNotFoundException;
|
||||||
use think\Request;
|
use think\Request;
|
||||||
@@ -78,7 +79,7 @@ class Loader
|
|||||||
$filename = $path . str_replace('\\', DS, $class) . EXT;
|
$filename = $path . str_replace('\\', DS, $class) . EXT;
|
||||||
if (is_file($filename)) {
|
if (is_file($filename)) {
|
||||||
// 开启调试模式Win环境严格区分大小写
|
// 开启调试模式Win环境严格区分大小写
|
||||||
if (APP_DEBUG && IS_WIN && false === strpos(realpath($filename), $class . EXT)) {
|
if (App::$debug && IS_WIN && false === strpos(realpath($filename), $class . EXT)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
include $filename;
|
include $filename;
|
||||||
@@ -253,7 +254,7 @@ class Loader
|
|||||||
$filename = $baseUrl . $class . $ext;
|
$filename = $baseUrl . $class . $ext;
|
||||||
if (is_file($filename)) {
|
if (is_file($filename)) {
|
||||||
// 开启调试模式Win环境严格区分大小写
|
// 开启调试模式Win环境严格区分大小写
|
||||||
if (APP_DEBUG && IS_WIN && false === strpos(realpath($filename), $class . $ext)) {
|
if (App::$debug && IS_WIN && false === strpos(realpath($filename), $class . $ext)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
include $filename;
|
include $filename;
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
namespace think;
|
namespace think;
|
||||||
|
|
||||||
|
use think\App;
|
||||||
|
|
||||||
class Log
|
class Log
|
||||||
{
|
{
|
||||||
const LOG = 'log';
|
const LOG = 'log';
|
||||||
@@ -45,7 +47,7 @@ class Log
|
|||||||
unset($config['type']);
|
unset($config['type']);
|
||||||
self::$driver = new $class($config);
|
self::$driver = new $class($config);
|
||||||
// 记录初始化信息
|
// 记录初始化信息
|
||||||
APP_DEBUG && Log::record('[ LOG ] INIT ' . $type . ': ' . var_export($config, true), 'info');
|
App::$debug && Log::record('[ LOG ] INIT ' . $type . ': ' . var_export($config, true), 'info');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -59,7 +61,7 @@ class Log
|
|||||||
unset($config['type']);
|
unset($config['type']);
|
||||||
self::$alarm = new $class($config['alarm']);
|
self::$alarm = new $class($config['alarm']);
|
||||||
// 记录初始化信息
|
// 记录初始化信息
|
||||||
APP_DEBUG && Log::record('[ CACHE ] ALARM ' . $type . ': ' . var_export($config, true), 'info');
|
App::$debug && Log::record('[ CACHE ] ALARM ' . $type . ': ' . var_export($config, true), 'info');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace think;
|
namespace think;
|
||||||
|
|
||||||
|
use think\App;
|
||||||
use think\Config;
|
use think\Config;
|
||||||
use think\Hook;
|
use think\Hook;
|
||||||
use think\Log;
|
use think\Log;
|
||||||
@@ -766,7 +767,7 @@ class Route
|
|||||||
{
|
{
|
||||||
if (!empty(self::$bind['type'])) {
|
if (!empty(self::$bind['type'])) {
|
||||||
// 记录绑定信息
|
// 记录绑定信息
|
||||||
APP_DEBUG && Log::record('[ BIND ] ' . var_export(self::$bind, true), 'info');
|
App::$debug && Log::record('[ BIND ] ' . var_export(self::$bind, true), 'info');
|
||||||
// 如果有URL绑定 则进行绑定检测
|
// 如果有URL绑定 则进行绑定检测
|
||||||
switch (self::$bind['type']) {
|
switch (self::$bind['type']) {
|
||||||
case 'class':
|
case 'class':
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace think;
|
namespace think;
|
||||||
|
|
||||||
|
use think\App;
|
||||||
use think\exception\ClassNotFoundException;
|
use think\exception\ClassNotFoundException;
|
||||||
|
|
||||||
class Session
|
class Session
|
||||||
@@ -45,7 +46,7 @@ class Session
|
|||||||
$config = Config::get('session');
|
$config = Config::get('session');
|
||||||
}
|
}
|
||||||
// 记录初始化信息
|
// 记录初始化信息
|
||||||
APP_DEBUG && Log::record('[ SESSION ] INIT ' . var_export($config, true), 'info');
|
App::$debug && Log::record('[ SESSION ] INIT ' . var_export($config, true), 'info');
|
||||||
$isDoStart = false;
|
$isDoStart = false;
|
||||||
if (isset($config['use_trans_sid'])) {
|
if (isset($config['use_trans_sid'])) {
|
||||||
ini_set('session.use_trans_sid', $config['use_trans_sid'] ? 1 : 0);
|
ini_set('session.use_trans_sid', $config['use_trans_sid'] ? 1 : 0);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace think;
|
namespace think;
|
||||||
|
|
||||||
|
use think\App;
|
||||||
use think\Cache;
|
use think\Cache;
|
||||||
use think\Config;
|
use think\Config;
|
||||||
use think\Request;
|
use think\Request;
|
||||||
@@ -326,7 +327,7 @@ class Url
|
|||||||
$route = is_array($route) ? $route[0] : $route;
|
$route = is_array($route) ? $route[0] : $route;
|
||||||
$item[$route][] = [$rule, [], []];
|
$item[$route][] = [$rule, [], []];
|
||||||
}
|
}
|
||||||
!APP_DEBUG && Cache::set('think_route_map', $item);
|
!App::$debug && Cache::set('think_route_map', $item);
|
||||||
return $item;
|
return $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
3
library/think/cache/driver/Redisd.php
vendored
3
library/think/cache/driver/Redisd.php
vendored
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace think\cache\driver;
|
namespace think\cache\driver;
|
||||||
|
|
||||||
|
use think\App;
|
||||||
use think\Cache;
|
use think\Cache;
|
||||||
use think\Exception;
|
use think\Exception;
|
||||||
use think\Log;
|
use think\Log;
|
||||||
@@ -148,7 +149,7 @@ class Redisd
|
|||||||
$this->handler->setOption(\Redis::OPT_PREFIX, $this->options['prefix']);
|
$this->handler->setOption(\Redis::OPT_PREFIX, $this->options['prefix']);
|
||||||
}
|
}
|
||||||
|
|
||||||
APP_DEBUG && Log::record("[ CACHE ] INIT Redisd : {$host}:{$port} master->" . var_export($master, true), Log::ALERT);
|
App::$debug && Log::record("[ CACHE ] INIT Redisd : {$host}:{$port} master->" . var_export($master, true), Log::ALERT);
|
||||||
} catch (\RedisException $e) {
|
} catch (\RedisException $e) {
|
||||||
//phpredis throws a RedisException object if it can't reach the Redis server.
|
//phpredis throws a RedisException object if it can't reach the Redis server.
|
||||||
//That can happen in case of connectivity issues, if the Redis service is down, or if the redis host is overloaded.
|
//That can happen in case of connectivity issues, if the Redis service is down, or if the redis host is overloaded.
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
namespace think\controller;
|
namespace think\controller;
|
||||||
|
|
||||||
|
use think\App;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ThinkPHP Hprose控制器类
|
* ThinkPHP Hprose控制器类
|
||||||
*/
|
*/
|
||||||
@@ -45,7 +47,7 @@ abstract class Hprose
|
|||||||
$methods = array_diff($methods, array('__construct', '__call', '_initialize'));
|
$methods = array_diff($methods, array('__construct', '__call', '_initialize'));
|
||||||
}
|
}
|
||||||
$server->addMethods($methods, $this);
|
$server->addMethods($methods, $this);
|
||||||
if (APP_DEBUG || $this->debug) {
|
if (App::$debug || $this->debug) {
|
||||||
$server->setDebugEnabled(true);
|
$server->setDebugEnabled(true);
|
||||||
}
|
}
|
||||||
// Hprose设置
|
// Hprose设置
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace think\controller;
|
namespace think\controller;
|
||||||
|
|
||||||
|
use think\App;
|
||||||
/**
|
/**
|
||||||
* ThinkPHP RPC控制器类
|
* ThinkPHP RPC控制器类
|
||||||
*/
|
*/
|
||||||
@@ -43,7 +44,7 @@ abstract class Rpc
|
|||||||
}
|
}
|
||||||
$server->add($methods, $this);
|
$server->add($methods, $this);
|
||||||
|
|
||||||
if (APP_DEBUG || $this->debug) {
|
if (App::$debug || $this->debug) {
|
||||||
$server->setDebugMode(true);
|
$server->setDebugMode(true);
|
||||||
}
|
}
|
||||||
$server->setEnableGZIP(true);
|
$server->setEnableGZIP(true);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ namespace think\db;
|
|||||||
|
|
||||||
use PDO;
|
use PDO;
|
||||||
use PDOStatement;
|
use PDOStatement;
|
||||||
|
use think\App;
|
||||||
use think\Collection;
|
use think\Collection;
|
||||||
use think\Db;
|
use think\Db;
|
||||||
use think\db\Query;
|
use think\db\Query;
|
||||||
@@ -260,7 +261,7 @@ abstract class Connection
|
|||||||
}
|
}
|
||||||
$this->links[$linkNum] = new PDO($config['dsn'], $config['username'], $config['password'], $params);
|
$this->links[$linkNum] = new PDO($config['dsn'], $config['username'], $config['password'], $params);
|
||||||
// 记录数据库连接信息
|
// 记录数据库连接信息
|
||||||
APP_DEBUG && Log::record('[ DB ] CONNECT: ' . $config['dsn'], 'info');
|
App::$debug && Log::record('[ DB ] CONNECT: ' . $config['dsn'], 'info');
|
||||||
} catch (\PDOException $e) {
|
} catch (\PDOException $e) {
|
||||||
if ($autoConnection) {
|
if ($autoConnection) {
|
||||||
Log::record($e->getMessage(), 'error');
|
Log::record($e->getMessage(), 'error');
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
namespace think\exception;
|
namespace think\exception;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use think\App;
|
||||||
use think\Config;
|
use think\Config;
|
||||||
use think\Console;
|
use think\Console;
|
||||||
use think\console\Output;
|
use think\console\Output;
|
||||||
@@ -35,7 +36,7 @@ class Handle
|
|||||||
{
|
{
|
||||||
if (!$this->isIgnoreReport($exception)) {
|
if (!$this->isIgnoreReport($exception)) {
|
||||||
// 收集异常数据
|
// 收集异常数据
|
||||||
if (APP_DEBUG) {
|
if (App::$debug) {
|
||||||
$data = [
|
$data = [
|
||||||
'file' => $exception->getFile(),
|
'file' => $exception->getFile(),
|
||||||
'line' => $exception->getLine(),
|
'line' => $exception->getLine(),
|
||||||
@@ -86,7 +87,7 @@ class Handle
|
|||||||
*/
|
*/
|
||||||
public function renderForConsole(Output $output, Exception $e)
|
public function renderForConsole(Output $output, Exception $e)
|
||||||
{
|
{
|
||||||
if (APP_DEBUG) {
|
if (App::$debug) {
|
||||||
$output->setVerbosity(Output::VERBOSITY_DEBUG);
|
$output->setVerbosity(Output::VERBOSITY_DEBUG);
|
||||||
}
|
}
|
||||||
(new Console)->renderException($e, $output);
|
(new Console)->renderException($e, $output);
|
||||||
@@ -100,7 +101,7 @@ class Handle
|
|||||||
{
|
{
|
||||||
$status = $e->getStatusCode();
|
$status = $e->getStatusCode();
|
||||||
$template = Config::get('http_exception_template');
|
$template = Config::get('http_exception_template');
|
||||||
if (!APP_DEBUG && !empty($template[$status])) {
|
if (!App::$debug && !empty($template[$status])) {
|
||||||
return Response::create($template[$status], 'view')->vars(['e' => $e])->send();
|
return Response::create($template[$status], 'view')->vars(['e' => $e])->send();
|
||||||
} else {
|
} else {
|
||||||
return $this->convertExceptionToResponse($e);
|
return $this->convertExceptionToResponse($e);
|
||||||
@@ -114,7 +115,7 @@ class Handle
|
|||||||
protected function convertExceptionToResponse(Exception $exception)
|
protected function convertExceptionToResponse(Exception $exception)
|
||||||
{
|
{
|
||||||
// 收集异常数据
|
// 收集异常数据
|
||||||
if (APP_DEBUG) {
|
if (App::$debug) {
|
||||||
// 调试模式,获取详细的错误信息
|
// 调试模式,获取详细的错误信息
|
||||||
$data = [
|
$data = [
|
||||||
'name' => get_class($exception),
|
'name' => get_class($exception),
|
||||||
@@ -144,7 +145,7 @@ class Handle
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!APP_DEBUG && !Config::get('show_error_msg')) {
|
if (!App::$debug && !Config::get('show_error_msg')) {
|
||||||
// 不显示详细错误信息
|
// 不显示详细错误信息
|
||||||
$data['message'] = Config::get('error_message');
|
$data['message'] = Config::get('error_message');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class Php
|
|||||||
throw new TemplateNotFoundException('template file not exists:' . $template, $template);
|
throw new TemplateNotFoundException('template file not exists:' . $template, $template);
|
||||||
}
|
}
|
||||||
// 记录视图信息
|
// 记录视图信息
|
||||||
APP_DEBUG && Log::record('[ VIEW ] ' . $template . ' [ ' . var_export(array_keys($data), true) . ' ]', 'info');
|
App::$debug && Log::record('[ VIEW ] ' . $template . ' [ ' . var_export(array_keys($data), true) . ' ]', 'info');
|
||||||
extract($data, EXTR_OVERWRITE);
|
extract($data, EXTR_OVERWRITE);
|
||||||
include $template;
|
include $template;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ class Think
|
|||||||
throw new TemplateNotFoundException('template file not exists:' . $template, $template);
|
throw new TemplateNotFoundException('template file not exists:' . $template, $template);
|
||||||
}
|
}
|
||||||
// 记录视图信息
|
// 记录视图信息
|
||||||
APP_DEBUG && Log::record('[ VIEW ] ' . $template . ' [ ' . var_export(array_keys($data), true) . ' ]', 'info');
|
App::$debug && Log::record('[ VIEW ] ' . $template . ' [ ' . var_export(array_keys($data), true) . ' ]', 'info');
|
||||||
$this->template->fetch($template, $data, $config);
|
$this->template->fetch($template, $data, $config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,11 +27,6 @@ if (is_file(ROOT_PATH . 'env' . EXT)) {
|
|||||||
putenv("$name=$val");
|
putenv("$name=$val");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 自动识别调试模式
|
|
||||||
if (!defined('APP_DEBUG')) {
|
|
||||||
$debug = getenv(ENV_PREFIX . 'APP_DEBUG');
|
|
||||||
define('APP_DEBUG', $debug);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 加载模式定义文件
|
// 加载模式定义文件
|
||||||
$mode = require MODE_PATH . APP_MODE . EXT;
|
$mode = require MODE_PATH . APP_MODE . EXT;
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ return [
|
|||||||
// 数据库表前缀
|
// 数据库表前缀
|
||||||
'prefix' => '',
|
'prefix' => '',
|
||||||
// 数据库调试模式
|
// 数据库调试模式
|
||||||
'debug' => APP_DEBUG,
|
'debug' => true,
|
||||||
// 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
|
// 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
|
||||||
'deploy' => 0,
|
'deploy' => 0,
|
||||||
// 数据库读写是否分离 主从式有效
|
// 数据库读写是否分离 主从式有效
|
||||||
|
|||||||
@@ -15,8 +15,6 @@ $_SERVER['REQUEST_METHOD'] = 'GET';
|
|||||||
define('TEST_PATH', __DIR__ . '/');
|
define('TEST_PATH', __DIR__ . '/');
|
||||||
// 定义项目路径
|
// 定义项目路径
|
||||||
define('APP_PATH', __DIR__ . '/application/');
|
define('APP_PATH', __DIR__ . '/application/');
|
||||||
// 开启调试模式
|
|
||||||
define('APP_DEBUG', true);
|
|
||||||
// 关闭应用自动执行
|
// 关闭应用自动执行
|
||||||
define('APP_AUTO_RUN', false);
|
define('APP_AUTO_RUN', false);
|
||||||
// 加载框架引导文件
|
// 加载框架引导文件
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ class baseTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertNotEmpty(TEMP_PATH);
|
$this->assertNotEmpty(TEMP_PATH);
|
||||||
$this->assertNotEmpty(VENDOR_PATH);
|
$this->assertNotEmpty(VENDOR_PATH);
|
||||||
$this->assertNotEmpty(EXT);
|
$this->assertNotEmpty(EXT);
|
||||||
$this->assertTrue(is_bool(APP_DEBUG));
|
|
||||||
$this->assertNotEmpty(ENV_PREFIX);
|
$this->assertNotEmpty(ENV_PREFIX);
|
||||||
$this->assertTrue(is_bool(IS_API));
|
$this->assertTrue(is_bool(IS_API));
|
||||||
$this->assertNotEmpty(APP_MODE);
|
$this->assertNotEmpty(APP_MODE);
|
||||||
|
|||||||
@@ -181,7 +181,7 @@
|
|||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<?php if(APP_DEBUG) { ?>
|
<?php if(\think\App::$debug) { ?>
|
||||||
<div class="exception">
|
<div class="exception">
|
||||||
<div class="message">
|
<div class="message">
|
||||||
|
|
||||||
@@ -309,7 +309,7 @@
|
|||||||
<span>V<?php echo THINK_VERSION; ?></span>
|
<span>V<?php echo THINK_VERSION; ?></span>
|
||||||
<span>{ 十年磨一剑-为API开发设计的高性能框架 }</span>
|
<span>{ 十年磨一剑-为API开发设计的高性能框架 }</span>
|
||||||
</div>
|
</div>
|
||||||
<?php if(APP_DEBUG) { ?>
|
<?php if(\think\App::$debug) { ?>
|
||||||
<script>
|
<script>
|
||||||
var LINE = <?php echo $line; ?>;
|
var LINE = <?php echo $line; ?>;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user