mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
Merge branch 'master' of https://github.com/top-think/framework
This commit is contained in:
@@ -69,6 +69,7 @@ class Error
|
|||||||
|
|
||||||
// 记录异常日志
|
// 记录异常日志
|
||||||
Log::record($log, 'error');
|
Log::record($log, 'error');
|
||||||
|
Log::save();
|
||||||
|
|
||||||
/* 非API模式下的部署模式,跳转到指定的 Error Page */
|
/* 非API模式下的部署模式,跳转到指定的 Error Page */
|
||||||
$error_page = Config::get('error_page');
|
$error_page = Config::get('error_page');
|
||||||
|
|||||||
@@ -61,17 +61,11 @@ class Response
|
|||||||
$handler = !empty($_GET[Config::get('var_jsonp_handler')]) ? $_GET[Config::get('var_jsonp_handler')] : Config::get('default_jsonp_handler');
|
$handler = !empty($_GET[Config::get('var_jsonp_handler')]) ? $_GET[Config::get('var_jsonp_handler')] : Config::get('default_jsonp_handler');
|
||||||
$data = $handler . '(' . json_encode($data, JSON_UNESCAPED_UNICODE) . ');';
|
$data = $handler . '(' . json_encode($data, JSON_UNESCAPED_UNICODE) . ');';
|
||||||
break;
|
break;
|
||||||
case '':
|
|
||||||
case 'html':
|
|
||||||
case 'text':
|
|
||||||
// 不做处理
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
// 用于扩展其他返回格式数据
|
|
||||||
APP_HOOK && Hook::listen('return_data', $data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
APP_HOOK && Hook::listen('return_data', $data);
|
||||||
|
|
||||||
if ($return) {
|
if ($return) {
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace think\console\output;
|
|||||||
|
|
||||||
use think\console\Output;
|
use think\console\Output;
|
||||||
|
|
||||||
class Null extends Output
|
class Nothing extends Output
|
||||||
{
|
{
|
||||||
/** @noinspection PhpMissingParentConstructorInspection */
|
/** @noinspection PhpMissingParentConstructorInspection */
|
||||||
public function __construct()
|
public function __construct()
|
||||||
@@ -27,17 +27,6 @@ return [
|
|||||||
'think\Error' => MODE_PATH . 'console/Error' . EXT
|
'think\Error' => MODE_PATH . 'console/Error' . EXT
|
||||||
],
|
],
|
||||||
// 配置文件
|
// 配置文件
|
||||||
'config' => [
|
'config' => THINK_PATH . 'convention' . EXT
|
||||||
'log' => [
|
|
||||||
'type' => 'File', // 支持 file socket trace sae
|
|
||||||
'path' => LOG_PATH,
|
|
||||||
],
|
|
||||||
'cache' => [
|
|
||||||
'type' => 'File',
|
|
||||||
'path' => CACHE_PATH,
|
|
||||||
'prefix' => '',
|
|
||||||
'expire' => 0,
|
|
||||||
]
|
|
||||||
]
|
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ class App
|
|||||||
*/
|
*/
|
||||||
public static function run()
|
public static function run()
|
||||||
{
|
{
|
||||||
|
self::init();
|
||||||
|
|
||||||
// 实例化console
|
// 实例化console
|
||||||
$console = new Console('Think Console', '0.1');
|
$console = new Console('Think Console', '0.1');
|
||||||
// 读取指令集
|
// 读取指令集
|
||||||
@@ -40,4 +42,67 @@ class App
|
|||||||
// 运行
|
// 运行
|
||||||
$console->run();
|
$console->run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static function init()
|
||||||
|
{
|
||||||
|
// 加载初始化文件
|
||||||
|
if (is_file(APP_PATH . 'init' . EXT)) {
|
||||||
|
include APP_PATH . 'init' . EXT;
|
||||||
|
|
||||||
|
// 加载模块配置
|
||||||
|
$config = Config::get();
|
||||||
|
} else {
|
||||||
|
// 加载模块配置
|
||||||
|
$config = Config::load(APP_PATH . 'config' . EXT);
|
||||||
|
|
||||||
|
// 加载应用状态配置
|
||||||
|
if ($config['app_status']) {
|
||||||
|
$config = Config::load(APP_PATH . $config['app_status'] . EXT);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 读取扩展配置文件
|
||||||
|
if ($config['extra_config_list']) {
|
||||||
|
foreach ($config['extra_config_list'] as $name => $file) {
|
||||||
|
$filename = APP_PATH . $file . EXT;
|
||||||
|
Config::load($filename, is_string($name) ? $name : pathinfo($filename, PATHINFO_FILENAME));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载别名文件
|
||||||
|
if (is_file(APP_PATH . 'alias' . EXT)) {
|
||||||
|
Loader::addMap(include APP_PATH . 'alias' . EXT);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载行为扩展文件
|
||||||
|
if (APP_HOOK && is_file(APP_PATH . 'tags' . EXT)) {
|
||||||
|
Hook::import(include APP_PATH . 'tags' . EXT);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载公共文件
|
||||||
|
if (is_file(APP_PATH . 'common' . EXT)) {
|
||||||
|
include APP_PATH . 'common' . EXT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 注册根命名空间
|
||||||
|
if (!empty($config['root_namespace'])) {
|
||||||
|
Loader::addNamespace($config['root_namespace']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载额外文件
|
||||||
|
if (!empty($config['extra_file_list'])) {
|
||||||
|
foreach ($config['extra_file_list'] as $file) {
|
||||||
|
$file = strpos($file, '.') ? $file : APP_PATH . $file . EXT;
|
||||||
|
if (is_file($file)) {
|
||||||
|
include_once $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置系统时区
|
||||||
|
date_default_timezone_set($config['default_timezone']);
|
||||||
|
|
||||||
|
// 监听app_init
|
||||||
|
APP_HOOK && Hook::listen('app_init');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user