ob_end_clean错误,ThinkPHP5.1.23
来源:7-5 让Swoole完美支持TP5(下)
Superman007
2018-09-15
$http = new swoole_http_server("0.0.0.0", 8899);
$http->set([
'enable_static_handler' => true,
'document_root' => '/media/psf/Home/PhpstormProjects/swoole.live.ipuxin.com/public/static',
'worker_num' => 4,
]);
$http->on('WorkerStart', function (swoole_server $server, $worker_id) {
//定义应用目录
define('APP_PATH', __DIR__ . '/../../application/');
//加载基础文件
require __DIR__ . '/../base.php';
});
$http->on('request', function ($request, $response) use($http) {
if (isset($request->server)) {
foreach ($request->server as $key => $item) {
$_SERVER[strtoupper($key)] = $item;
}
}
if (isset($request->header)) {
foreach ($request->header as $key => $item) {
$_SERVER[strtoupper($key)] = $item;
}
}
if (isset($request->get)) {
foreach ($request->get as $key => $item) {
$_GET[$key] = $item;
}
}
if (isset($request->post)) {
foreach ($request->post as $key => $item) {
$_POST[$key] = $item;
}
}
ob_start();
try {
// 执行应用并响应
\think\Container::get('app', [APP_PATH])->run()->send();
} catch (\Exception $e) {
echo "TP5 Error";
}
// $action = request()->action();
// echo $action;
$result = ob_get_contents();
ob_end_clean();
$response->end("This get is: " . json_encode($result));
});
$http->start();
[parallels@swoole ~]$ php /media/psf/Home/PhpstormProjects/swoole.live.ipuxin.com/thinkphp/server/http_server.php
This is form controller! dfasdfPHP Fatal error: Uncaught think\exception\ErrorException: ob_end_clean(): failed to delete buffer. No bu
ffer to delete in /media/psf/Home/PhpstormProjects/swoole.live.ipuxin.com/thinkphp/server/http_server.php:65
Stack trace:
#0 [internal function]: think\Error::appError(8, 'ob_end_clean():...', '/media/psf/Home...', 65, Array)
#1 /media/psf/Home/PhpstormProjects/swoole.live.ipuxin.com/thinkphp/server/http_server.php(65): ob_end_clean()
#2 {main}
thrown in /media/psf/Home/PhpstormProjects/swoole.live.ipuxin.com/thinkphp/server/http_server.php on line 65
[think\exception\ErrorException]
Uncaught think\exception\ErrorException: ob_end_clean(): failed to delete buffer. No buffer to delete in /media/psf/Home/PhpstormPr
ojects/swoole.live.ipuxin.com/thinkphp/server/http_server.php:65
Stack trace:
#0 [internal function]: think\Error::appError(8, 'ob_end_clean():...', '/media/psf/Home...', 65, Array)
#1 /media/psf/Home/PhpstormProjects/swoole.live.ipuxin.com/thinkphp/server/http_server.php(65): ob_end_clean()
#2 {main}
thrown
[2018-09-13 06:17:15 *11781.2] ERROR zm_deactivate_swoole (ERROR 503): Fatal error: Uncaught think\exception\ErrorException: ob_end_c
lean(): failed to delete buffer. No buffer to delete in /media/psf/Home/PhpstormProjects/swoole.live.ipuxin.com/thinkphp/server/http_ser
ver.php:65
Stack trace:
#0 [internal function]: think\Error::appError(8, 'ob_end_clean():...', '/media/psf/Home...', 65, Array)
#1 /media/psf/Home/PhpstormProjects/swoole.live.ipuxin.com/thinkphp/server/http_server.php(65): ob_end_clean()
#2 {main}
thrown in /media/psf/Home/Ph
[2018-09-13 06:17:15 $11774.0] WARNING swManager_check_exit_status: worker#2 abnormal exit, status=255, signal=0
写回答
2回答
-
Superman007
提问者
2018-09-24
你好老师,我用最新的thinkphp版本,和swoole搭配,但是不知道怎么和咱们的课程结合,能增加一节课,讲一下么?
00 -
singwa
2018-09-15
同学您好。可能和版本有关系。
thinkphp 你这个版本现在官网支持swoole了。 你关注下官网里面有说明, 这样就可以不用用老师那种用thinkphp适配swoole了, 您可以看看。祝您学习愉快。
032018-09-17
相似问题