PHPackages                             kegi/php-error-handler - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. kegi/php-error-handler

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

kegi/php-error-handler
======================

0.1.7(7y ago)455PHPPHP &gt;=7.0

Since Sep 10Pushed 7y ago1 watchersCompare

[ Source](https://github.com/kegi/php-error-handler)[ Packagist](https://packagist.org/packages/kegi/php-error-handler)[ RSS](/packages/kegi-php-error-handler/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (2)Versions (9)Used By (0)

php-error-handler
=================

[](#php-error-handler)

PHP7; Object oriented error handler. **This is an alpha version**.

\#Introduction

This error handler detects PHP errors, convert them into exceptions and let you handle them easilly. Aditionnaly, this library handle the output buffering to avoid uncompleted body response. This library optionnaly log errors (accepts PSR Interface).

Installation
------------

[](#installation)

Install this library with Composer

```
composer require kegi/php-error-handler
```

Debug mode
----------

[](#debug-mode)

***disabled** by default*

- With debug **enabled**, errors are displayed normally (you are still notifided).
- With debug **disabled**, all errors are hidden, you are notified and it's your job to return an error message.

Strict mode
-----------

[](#strict-mode)

***disabled** by default*

Strict mode will convert all non-fatal errors into fatal errors.

### Complexe error handling runtime

[](#complexe-error-handling-runtime)

You can execute complexe code if a fatal error is detected. (eg. you can call your errorController, build a response from a template according to the user's language settings...)

If an other fatal error occured while handling this fatal error... (eg. a fatal error on the core of your app), you'll be notified that an unrecoverable error occured and you'll be able to return an error message (eg. return the content of a static error html page).

\#How to implement it on your project

1. you instanciate PhpErrorHandler at the very beggining of your project.
2. you provided a callable function for the wanted error level (non-fatal, fatal and unrecoverable).
3. the uncaught exception of your project will naturally go on your fatal error method. You don't need to handle them differently anymore.

\#Example

```
