Whoops

7/8/2021

# 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 (opens new window)

# 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();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

# 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);
1
2
3
4
5

whoops-custom.css (opens new window)


Packagist: https://packagist.org/packages/nin/nin (opens new window)