PHPackages                             logger/errorhandling - 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. logger/errorhandling

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

logger/errorhandling
====================

Errorhandling extension for PSR-3 compatible loggers

1.0.1(7mo ago)02.3k1MITPHPPHP &gt;= 8.0

Since Nov 20Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/LoggerEssentials/ErrorHandling)[ Packagist](https://packagist.org/packages/logger/errorhandling)[ RSS](/packages/logger-errorhandling/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (10)Dependencies (4)Versions (21)Used By (0)

ErrorHandling
=============

[](#errorhandling)

[![Latest Stable Version](https://camo.githubusercontent.com/0bae7fbc7c153cd3a3392b29ec61743ba6298130cc7196cb51e5d6e50faeb658/68747470733a2f2f706f7365722e707567782e6f72672f6c6f676765722f6572726f7268616e646c696e672f76657273696f6e2e737667)](https://packagist.org/packages/logger/errorhandling)[![License](https://camo.githubusercontent.com/993e630533afc41f73556fe614a24c7e2715ea303db7f2dc37d6ef24b3d996f1/68747470733a2f2f706f7365722e707567782e6f72672f6c6f676765722f6572726f7268616e646c696e672f6c6963656e73652e737667)](https://packagist.org/packages/logger/errorhandling)

Overview

- ErrorHandling provides drop‑in handlers that route all PHP problems to your PSR‑3 logger: notices, warnings, deprecations, assertions, exceptions, and many fatals.
- Designed for modern PHP (8.x, incl. 8.5) and integrates with logger/essentials out of the box, but works with any PSR‑3 `LoggerInterface`.

Requirements

- PHP &gt;= 8.0
- A PSR‑3 compatible logger (e.g., `logger/essentials`)

Install

- Composer: `composer require logger/errorhandling`

Quick Start

```
use Logger\CoreErrorHandlers;
use Psr\Log\LogLevel;

// Turn PHP errors into exceptions (configurable mask, defaults to E_ALL)
CoreErrorHandlers::enableExceptionsForErrors();

// Log assertions through your PSR-3 logger at a chosen level
CoreErrorHandlers::registerAssertionHandler($logger, LogLevel::WARNING);

// Log uncaught exceptions (and print a compact stack trace to STDERR)
CoreErrorHandlers::registerExceptionHandler($logger);

// Log fatal errors such as E_ERROR/E_PARSE/E_CORE_ERROR/E_COMPILE_ERROR
CoreErrorHandlers::registerFatalErrorHandler($logger);
```

What It Does

- Exceptions for errors: Converts PHP error levels (by bitmask) into `ErrorException` you can catch, or let bubble into the exception handler.
- Assertion logging: Captures `assert()` callbacks and logs message + file/line without emitting warnings.
- Exception logging: Catches uncaught `Throwable`, logs at `critical`, and prints a readable stack trace to STDERR before exiting with status 1.
- Fatal error logging: On shutdown, inspects the last error and logs `alert` for typical fatal types.

API

- `CoreErrorHandlers::enableExceptionsForErrors(int $bitmask = E_ALL): void`
    - Throw `ErrorException` for any error whose level matches `$bitmask`.
- `CoreErrorHandlers::registerAssertionHandler(LoggerInterface $logger, string $logLevel): void`
    - Route failed assertions to `$logger` at the given PSR‑3 level, with `file` and `line` context.
- `CoreErrorHandlers::registerExceptionHandler(LoggerInterface $logger): void`
    - Log uncaught exceptions as `critical` with rich context; prints stack trace and exits with code 1.
- `CoreErrorHandlers::registerFatalErrorHandler(LoggerInterface $logger): void`
    - On shutdown, log last fatal error (`E_ERROR`, `E_PARSE`, `E_CORE_ERROR`, `E_COMPILE_ERROR`) as `alert`.

Configuration Tips

- Call the registration methods early in your bootstrap so problems are captured.
- You can combine handlers (typical usage registers all of them).
- To exclude specific severities from becoming exceptions, pass a masked bitmask, e.g. `E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED`.

Development

- Run tests: `composer run tests`
- Static analysis: `composer run phpstan`

Compatibility Notes

- `E_STRICT` is not handled specially (folded into other levels on modern PHP).
- Handlers use `Throwable`, not just `Exception`, to cover engine errors in PHP 7/8.

License

- MIT — see LICENSE for details.

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance65

Regular maintenance activity

Popularity21

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity77

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~211 days

Recently: every ~676 days

Total

20

Last Release

211d ago

Major Versions

0.2 → 1.0.02025-11-22

PHP version history (3 changes)0.0.1PHP &gt;= 5.3

0.2PHP &gt;= 7.0

1.0.0PHP &gt;= 8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/22354384?v=4)[logger](/maintainers/logger)[@logger](https://github.com/logger)

---

Top Contributors

[![rkrx](https://avatars.githubusercontent.com/u/5672982?v=4)](https://github.com/rkrx "rkrx (36 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Type Coverage Yes

### Embed Badge

![Health badge](/badges/logger-errorhandling/health.svg)

```
[![Health](https://phpackages.com/badges/logger-errorhandling/health.svg)](https://phpackages.com/packages/logger-errorhandling)
```

###  Alternatives

[psr/log

Common interface for logging libraries

10.4k1.2B10.8k](/packages/psr-log)[open-telemetry/api

API for OpenTelemetry PHP.

1938.5M261](/packages/open-telemetry-api)[open-telemetry/sdk

SDK for OpenTelemetry PHP.

2326.5M315](/packages/open-telemetry-sdk)[illuminated/console-logger

Logging and Notifications for Laravel Console Commands.

8676.7k](/packages/illuminated-console-logger)[relaxart/monolog-docker-handler

Docker handler for monolog

1442.6k](/packages/relaxart-monolog-docker-handler)

PHPackages © 2026

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