Whoops
8/8/25Less than 1 minute
Description
- Whoops là 1 thư viện handle error của PHP
- Hổ trợ debug và view pretty error.
Document: http://filp.github.io/whoops
Triễn khai Whoops:
$whoops = new Whoops\Run();
$whoops->pushHandler(new Whoops\Handler\PrettyPageHandler());
// Configure the PrettyPageHandler:
$handler = new \Whoops\Handler\PrettyPageHandler;
$handler->setPageTitle("It's broken!")->setEditor("phpstorm");
$whoops->pushHandler($handler);
if (\Whoops\Util\Misc::isAjaxRequest()) {
$whoops->pushHandler(new \Whoops\Handler\JsonResponseHandler);
}
// Set Whoops as the default error and exception handler used by PHP:
$whoops->register();
Thay đổi giao diện:
Whoops cho phép add css vào giao diện debug
$directory = 'vendor/whoops';
$css = '/whoops-custom.css';
$handler->addResourcePath($directory);
$handler->addCustomCss($css);
Packagist: https://packagist.org/packages/nin/nin