PHP code example of awesomite / error-dumper
1. Go to this page and download the library: Download awesomite/error-dumper library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
awesomite / error-dumper example snippets
use Awesomite\ErrorDumper\Handlers\ErrorHandler;
use Awesomite\ErrorDumper\Listeners\OnExceptionCallable;
use Awesomite\ErrorDumper\Listeners\OnExceptionDevView;
use Awesomite\ErrorDumper\Views\ViewFactory;
/**
* Create new error handler.
* If $mode is null will be used default value E_ALL | E_STRICT.
*
* @see http://php.net/manual/en/errorfunc.constants.php
*/
$handler = new ErrorHandler(/* optional $mode = null */);
/**
* Create and push new error listener,
* this handler will print programmer-friendly stack trace.
*/
$devViewListener = new OnExceptionDevView(ViewFactory::create());
$handler->pushListener($devViewListener);
/**
* Create and push new custom error listener.
*/
$handler->pushListener(new OnExceptionCallable(function ($exception) {
// do something with $exception
}));
/**
* Create and push new custom error listener,
* this handler will be used only when $exception is instance of \RuntimeException.
*/
$handler->pushListener(new OnExceptionCallable(function (\RuntimeException $exception) {
// do something with $exception
}));
/**
* Exit script when error has been detected after executing all listeners.
*/
$handler->exitAfterTrigger(true);
/**
* Register error handler.
*
* Possible types:
* - ErrorHandler::TYPE_ERROR
* - ErrorHandler::TYPE_EXCEPTION
* - ErrorHandler::TYPE_FATAL_ERROR
*/
$handler->register(/* optional bitmask $types = ErrorHandler::TYPE_ALL */);