目录结构调整
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
namespace think;
|
||||
|
||||
use think\Config;
|
||||
use think\debug\Trace;
|
||||
use think\Exception;
|
||||
use think\exception\HttpException;
|
||||
use think\exception\HttpResponseException;
|
||||
@@ -70,7 +71,7 @@ class App
|
||||
* 执行应用程序
|
||||
* @access public
|
||||
* @param Request $request Request对象
|
||||
* @return mixed
|
||||
* @return Response
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function run(Request $request = null)
|
||||
@@ -136,22 +137,29 @@ class App
|
||||
$data = $exception->getResponse();
|
||||
}
|
||||
|
||||
// 监听app_end
|
||||
Hook::listen('app_end', $data);
|
||||
// 清空类的实例化
|
||||
Loader::clearInstance();
|
||||
|
||||
// 输出数据到客户端
|
||||
if ($data instanceof Response) {
|
||||
return $data;
|
||||
$response = $data;
|
||||
} elseif (!is_null($data)) {
|
||||
// 默认自动识别响应输出类型
|
||||
$isAjax = $request->isAjax();
|
||||
$type = $isAjax ? Config::get('default_ajax_return') : Config::get('default_return_type');
|
||||
return Response::create($data, $type);
|
||||
$response = Response::create($data, $type);
|
||||
} else {
|
||||
return Response::create();
|
||||
$response = Response::create();
|
||||
}
|
||||
|
||||
|
||||
// 监听app_end
|
||||
Hook::listen('app_end', $response);
|
||||
|
||||
//注入Trace
|
||||
self::$debug && Trace::inject($response);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -349,6 +357,15 @@ class App
|
||||
self::$debug = Config::get('app_debug');
|
||||
if (!self::$debug) {
|
||||
ini_set('display_errors', 'Off');
|
||||
} else {
|
||||
//重新申请一块比较大的buffer
|
||||
if (ob_get_level() > 0) {
|
||||
$output = ob_get_clean();
|
||||
}
|
||||
ob_start();
|
||||
if (!empty($output)) {
|
||||
echo $output;
|
||||
}
|
||||
}
|
||||
|
||||
// 应用命名空间
|
||||
|
||||
Reference in New Issue
Block a user