PHPackages                             caseycs/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. caseycs/php-error-handler

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

caseycs/php-error-handler
=========================

Universal error, exception and cachable fatal errors handler

4698PHP

Since Oct 3Pushed 11y ago2 watchersCompare

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

READMEChangelogDependenciesVersions (2)Used By (0)

PHP error handler
=================

[](#php-error-handler)

Common error handling with callbacks. Provides custom error message with request url, referer, session and other environment info for every error.

Example:

```
SHUTDOWN Call to undefined function unexisted_function() in /Users/ikondrashov/github/php-error-handler/test/uncatchable.php:6
URL: localhost:3000/uncatchable.php
HTTP_REFERER: http://localhost:3000/uncatchable.php
SESSION: Array
(
    [a] => 5
)
POST: Array
(
    [b] => 10
)
COOKIES: Array
(
    [c] => 15
)
uniqid: 52496cfee1616

```

Installation via [Composer](http://getcomposer.org)

```
{
    "require": {
        "caseycs/php-error-handler": "dev-master"
    },
}

```

Usage
-----

[](#usage)

Basic usage:

```
$ErrorHandler = new ErrorHandler\ErrorHandler;
$ErrorHandler->register();
```

Advanced usage:

```
if ($_SERVER['APPLICATION_ENV'] !== 'development') {
    $ErrorHandler = new ErrorHandler\ErrorHandler;
    $ErrorHandler->register();
    $ErrorHandler->addExceptionCallback(function () {header ('HTTP/1.0 500 Internal Server Error', true, 500);});
}
```

Going deeper
------------

[](#going-deeper)

First of all - make sure, that you have `error_log` value defined - both for cli and fpm (or apache) environments. Use `phpinfo()` for web and `php -i | grep error_log` for cli. Make sure, that specified file is writeable for user, which executes your cli scripts (for example using crontab) and apache/fpm.

This is very important!

Also, make sure that `display_errors` equals false - this package is only for production usage.

What's our goals?

For cli we are going to write all errors to common cli error log `/var/log/php-errors-cli.php` **and** to stderr of running script - for example from crontab `* * * * * php script.php >> script.log 2>&1`.

For web we are going to write all errors to common web error log `/var/log/php-errors-fpm.php` **including** environment - url, referer, get, post, cookies, session etc. Also we want to write environment for uncatchable errors - which are handled by `register_shutdown_function`.

Drawbacks
---------

[](#drawbacks)

Fatal errors, which are not handled by `set_error_handler` and are caught only by `register_shutdown_function`appear in error log twice - first time as native php error, and second one - as our custom message with environment info. Anybody knowns how to fix this?

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/41736c206f72612ed210fa7b5dce5e56d3b31c70c551bcde8c870ac19043a36c?d=identicon)[caseycs](/maintainers/caseycs)

---

Top Contributors

[![caseycs](https://avatars.githubusercontent.com/u/76095?v=4)](https://github.com/caseycs "caseycs (23 commits)")

### Embed Badge

![Health badge](/badges/caseycs-php-error-handler/health.svg)

```
[![Health](https://phpackages.com/badges/caseycs-php-error-handler/health.svg)](https://phpackages.com/packages/caseycs-php-error-handler)
```

###  Alternatives

[psr/log

Common interface for logging libraries

10.4k1.2B9.2k](/packages/psr-log)[itsgoingd/clockwork

php dev tools in your browser

5.9k27.6M94](/packages/itsgoingd-clockwork)[graylog2/gelf-php

A php implementation to send log-messages to a GELF compatible backend like Graylog2.

41838.2M138](/packages/graylog2-gelf-php)[bugsnag/bugsnag-psr-logger

Official Bugsnag PHP PSR Logger.

32132.5M2](/packages/bugsnag-bugsnag-psr-logger)[consolidation/log

Improved Psr-3 / Psr\\Log logger based on Symfony Console components.

15462.2M7](/packages/consolidation-log)[datadog/php-datadogstatsd

An extremely simple PHP datadogstatsd client

19124.6M15](/packages/datadog-php-datadogstatsd)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
