whoops简介
whoops is a nice little library that helps you develop and maintain your projects better, by helping you deal with errors and exceptions in a less painful way.
whoops安装
使用composer安装
composer require filp/whoops
用法
require __DIR__."/../vendor/autoload.php";
$whoops = new Run;
$handler = new PrettyPageHandler;
$handler->setPageTitle("出现错误了");//设置报错页面的title
$whoops->pushHandler($handler);
if (Misc::isAjaxRequest()) {//设置处理ajax报错的信息
$whoops->pushHandler(new JsonResponseHandler);
}
$whoops->register();
//可以把这段代码放到任何可以放置的地方,只会捕捉其后面的错误。
报错页面
喜欢它的报错页面,可以快速的定位到报错的地方并在页面上查看报错的代码,方便快捷,这也是我喜欢它的原因。