setbased / error-handler
An error handler
Installs: 16 055
Dependents: 12
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=8.1
- setbased/exception: ^2.3.0
Requires (Dev)
- phing/phing: ^3.0.0-RC4
- phpunit/phpunit: ^9.5.28
This package is auto-updated.
Last update: 2024-12-26 09:29:26 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.