PHPackages                             memran/marwa-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. memran/marwa-error-handler

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

memran/marwa-error-handler
==========================

Framework-agnostic PHP error handling with PSR-3 logging, optional debug reporting, and safe fallback rendering.

v1.1.0(1mo ago)0881MITPHPPHP &gt;=8.1

Since Mar 29Pushed 6mo agoCompare

[ Source](https://github.com/memran/marwa-error-handler)[ Packagist](https://packagist.org/packages/memran/marwa-error-handler)[ RSS](/packages/memran-marwa-error-handler/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (2)Used By (1)

memran/marwa-error-handler
==========================

[](#memranmarwa-error-handler)

[![Latest Version](https://camo.githubusercontent.com/756891c7a1247ff9509ae771b2f52db9a2d9b54ccb510a7aac525a2f4d1ebefe/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d656d72616e2f6d617277612d6572726f722d68616e646c65722e737667)](https://packagist.org/packages/memran/marwa-error-handler)[![Total Downloads](https://camo.githubusercontent.com/824df2d805a2a0ffac315f2f0c571fa1426c146e12ad37097405d1bb608bd128/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d656d72616e2f6d617277612d6572726f722d68616e646c65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/memran/marwa-error-handler)[![PHP Version](https://camo.githubusercontent.com/ef67efd2d449cdf21a08a616d4f624aee895201d53b5db0fff0057fdaa2500de/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d656d72616e2f6d617277612d6572726f722d68616e646c6572)](https://php.net)[![License](https://camo.githubusercontent.com/82571d0f200c897f16d1d90650e9b764046c284a0cc4fc39729f9e58d7c98e26/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d656d72616e2f6d617277612d6572726f722d68616e646c6572)](LICENSE)

A tiny, framework-agnostic **PHP Error Handler** with:

- Optional **PSR-3 Logger** injection (logs if provided; no-op if not)
- Optional **Debugbar** injection (adds exception to bar in dev)
- **Professional fallback UI** when neither logger nor debugbar exists
- Clean **dev vs prod** behavior

Install
-------

[](#install)

```
composer require memran/marwa-error-handler
```

Example
=======

[](#example)

```
use Marwa\ErrorHandler\ErrorHandler;
use Marwa\ErrorHandler\Support\FallbackRenderer;

// (optional) Inject a PSR-3 logger and/or a Debugbar:
$logger   = null; // e.g., Monolog or your own PSR-3 logger
$debugbar = null; // object with addThrowable/addException/addMessage OR a callable(Throwable): void

ErrorHandler::bootstrap(
    appName: 'MyApp',
    env: 'production',    // 'development' or 'production'
    logger: $logger,
    debugbar: $debugbar,
    renderer: new FallbackRenderer() // optional; default will be created
);
```

Behavior
========

[](#behavior)

- **Development**

    - If a **Debugbar** is present: exception is added to the bar and rethrown so your dev page (Whoops/Symfony) renders.
    - If **no logger &amp; no debugbar**: a polished **dev exception page** is rendered with trimmed trace.
    - If a **logger** is present: php\_error, uncaught\_exception, and fatal\_shutdown entries are written.
- **Production**

    - If a **logger** is present: errors/exceptions/fatals are logged; the response returns **HTTP 500** without details.
    - If **no logger &amp; no debugbar**: a clean **generic error page** is rendered with only Request ID &amp; timestamp.

Optional DI
===========

[](#optional-di)

```
$handler = new ErrorHandler(appName: 'MyApp', env: 'development');
$handler->setLogger($logger);     // PSR-3
$handler->setDebugbar($debugbar); // object or callable
$handler->setRenderer(new FallbackRenderer());
$handler->register();
```

Testing
=======

[](#testing)

```
composer install
composer test
```

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance78

Regular maintenance activity

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity42

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

50d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8cf906a31a250a940314fe42f8a18f449647bfe18095457350ff0081cf8dd3c2?d=identicon)[memran](/maintainers/memran)

---

Top Contributors

[![memran](https://avatars.githubusercontent.com/u/7415198?v=4)](https://github.com/memran "memran (10 commits)")

---

Tags

psr-3phpdebugexceptionerror-handler

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/memran-marwa-error-handler/health.svg)

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

###  Alternatives

[analog/analog

Fast, flexible, easy PSR-3-compatible PHP logging package with dozens of handlers.

3451.5M24](/packages/analog-analog)[inpsyde/wonolog

Monolog-based logging package for WordPress.

183617.9k7](/packages/inpsyde-wonolog)[e2ex/e2ex

Converts PHP Errors to Exceptions and (optionally) logs PHP Errors, Notices and Warnings with a PSR-3 compatible logger

101.5k](/packages/e2ex-e2ex)

PHPackages © 2026

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