Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
100 lines (91 sloc) 2.89 KB


The Error provides more control over displaying and logging PHP errors.


composer require webiik/error


$error = new \Webiik\Error\Error();

Silent mode


setSilent(bool $bool): void

setSilent() activates or deactivates silent mode. When Error is not in silent mode it halts code execution on every error and then it displays error message. In silent mode instead of displaying error message a custom error page is shown and some errors can be completely ignored.



setSilentPageContent(string $string): void

setSilentPageContent() sets custom error page to be shown when error occurs in silent mode.

$error->setSilentPageContent('<h1>Ups! Kitten lost!</h1>');


setSilentIgnoreErrors(array $arr): void

setSilentIgnoreErrors() sets an array of error constants that will be ignored in silent mode - no custom error page will be shown and code execution will not stop.




setErrLogDefLevel(string $level): void

setErrLogDefLevel() associates PSR-3 log level to all PHP error constant. The default value is warning.


Note: Please keep on mind that PHP error constant (eg. E_NOTICE) and PSR-3 log level (eg. notice) are two different things and there is no connection between them.


setErrLogLevel(array $assocArr): void

setErrLogLevel() associates PSR-3 log level to specific PHP error constant. Default values are shown in the example below.

    'Exception' => 'error',
    'E_ERROR' => 'error',


setLogService(callable $function): void

setLogService() sets custom logger logging errors. function is injected with the following parameters: string $level, string $message, array $data. By default all PHP errors are logged with error_log().

$error->setLogService(function ($level, $message, $data) {
    // $level - PSR-3 log level
    // $message - Re-fromatted error message
    // $data - ['error type' => $errType, 'file' => $file, 'line' => $line, 'error message' => $message, 'trace' => $trace]
    // Your custom logger...


You can’t perform that action at this time.