setbased/error-handler

An error handler

1.3.0 2023-01-26 05:40 UTC

This package is auto-updated.

Last update: 2024-10-26 09:07:37 UTC


README

An error handler for PHP.

PHP is a great language, however is has some quirks. One of them is that PHP has two mechanisms for signaling errors: exceptions and warnings. The following code will by default not raise an exception:

$handle = fopen('no-such-file.txt', 'r');

It will generate a waring (which is most like to be suppressed) and return false.

This library will throw exceptions in case like above instead of generating warnings.

Manual

Add the following code at the beginning of your PHP script to throw exceptions (when possible) when a PHP warning, error, or notice occurs.

use SetBased\ErrorHandler\ErrorHandler;

$handler = new ErrorHandler();
$handler->registerErrorHandler(); 

Installation

This package can be installed using composer:

composer require setbased/error-handler

Or you can obtain the sources at GitHub.

License

This project is licensed under the terms of the MIT license.