soooldier/hyperf-whoops
Composer 安装命令:
composer require soooldier/hyperf-whoops
包简介
A whoops component for hyperf.
README 文档
README
让hyperf支持whoops显示异常信息
Features
- 开箱即用
How to use
composer require soooldier/hyperf-whoops
Api
Contents
getHtmlOutput
$whoops->getHtmlOutput()
getPlainTextOutput
$whoops->getPlainTextOutput()
getJsonOutput
$whoops->getJsonOutput()
Example
class AppExceptionHandler extends ExceptionHandler { /** * @var ContainerInterface */ private $container; /** * @var StdoutLoggerInterface */ private $logger; public function __construct(StdoutLoggerInterface $logger, ContainerInterface $container) { $this->logger = $logger; $this->container = $container; } public function handle(Throwable $throwable, ResponseInterface $response) { $whoops = $this->container->get('whoops'); $content = $whoops->getHtmlOutput($throwable); // 获取html格式输出,日志最详细 // $content = $whoops->getJsonOutput($throwable); // 获取json格式输出,通常配合ajax使用 // $content = $whoops->getPlainTextOutput($throwable); // 文本格式输出,通常记日志 return $response->withStatus(500)->withBody(new SwooleStream($content)); } public function isValid(Throwable $throwable): bool { return true; } }
ChangeLog
- v1.0.0 第一版
- v1.0.1 修复相同协程内数据污染问题
统计信息
- 总下载量: 43
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-07-03