Skip to content

SetBased/php-error-handler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ErrorHandler

An error handler for PHP.

Social Legal Release Tests Code
Gitter License Latest Stable Version
Build Status
Code Coverage
Scrutinizer Code Quality

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.