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.2.1(1mo ago)09823MITPHPPHP &gt;=8.1CI passing

Since Mar 29Pushed 1mo 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 today

READMEChangelogDependencies (8)Versions (4)Used By (3)

marwa-error-handler
===================

[](#marwa-error-handler)

[![Latest Version](https://camo.githubusercontent.com/756891c7a1247ff9509ae771b2f52db9a2d9b54ccb510a7aac525a2f4d1ebefe/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d656d72616e2f6d617277612d6572726f722d68616e646c65722e737667)](https://packagist.org/packages/memran/marwa-error-handler)[![Total Downloads](https://camo.githubusercontent.com/46c7ae1d349e2d3e9ca7b6ae2cd7ee782fe5cc027b61fe76998bb1800699063f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d656d72616e2f6d617277612d6572726f722d68616e646c65722e737667)](https://packagist.org/packages/memran/marwa-error-handler)[![License](https://camo.githubusercontent.com/4b5ec9b209e9b36d07c88ab56431dc450ef9a4bafc762247b733932b6f498f23/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d656d72616e2f6d617277612d6572726f722d68616e646c65722e737667)](LICENSE)[![PHP Version](https://camo.githubusercontent.com/e512375cd938ba290ea0441c3c04fa49c326c050b70e878003c0c07db1ad3674/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d656d72616e2f6d617277612d6572726f722d68616e646c65722e737667)](https://packagist.org/packages/memran/marwa-error-handler)[![CI](https://github.com/memran/marwa-error-handler/actions/workflows/ci.yml/badge.svg)](https://github.com/memran/marwa-error-handler/actions/workflows/ci.yml)[![Coverage](https://camo.githubusercontent.com/ef3eed79ebed75d03f410555e4e4c3e9de03b872aab833c765525ec27756e577/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6d656d72616e2f6d617277612d6572726f722d68616e646c65722e737667)](https://codecov.io/gh/memran/marwa-error-handler)[![PHPStan](https://camo.githubusercontent.com/b6d441ad4fe8332cb16c72aa27f22cc685181dfd74ae34964afc92c6c1146b3c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c2532306d61782d627269676874677265656e2e737667)](https://phpstan.org/)

Production-focused, framework-agnostic PHP error handling with PSR-3 logging, optional debug reporting, and safe fallback rendering for HTTP and CLI applications.

Requirements
------------

[](#requirements)

- PHP 8.1 or newer
- Composer
- Optional: a PSR-3 compatible logger such as Monolog

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

[](#installation)

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

Usage
-----

[](#usage)

```
use Marwa\ErrorHandler\ErrorHandler;

ErrorHandler::bootstrap(
    appName: 'MyApp',
    env: 'production',
    logger: $logger,
    debugbar: $debugReporter, // optional callable/object reporter
);
```

For manual wiring:

```
$handler = new ErrorHandler(appName: 'MyApp', env: 'development');
$handler->setLogger($logger);
$handler->setDebugbar($debugReporter);
$handler->register();
```

Configuration
-------------

[](#configuration)

- `appName`: used in logs and fallback pages.
- `env`: `development`, `dev`, `local`, and `debug` enable detailed dev output.
- `logger`: any `Psr\Log\LoggerInterface`; logger failures are safely ignored.
- `debugbar`: optional callable or object with `addThrowable()`, `addException()`, or `addMessage()`.
- `renderer`: optional custom `RendererInterface` implementation for full control over output.

Safe defaults:

- Production never renders exception details in HTML.
- CLI output stays concise in production.
- Request IDs from headers are validated before being echoed.

Testing
-------

[](#testing)

```
composer install
composer test
composer test:coverage
```

Static Analysis
---------------

[](#static-analysis)

```
composer analyse
composer lint
composer fix
```

PHPStan runs at max level against `src/`. PHP-CS-Fixer enforces PSR-12-oriented formatting.

CI/CD
-----

[](#cicd)

GitHub Actions runs the package on PHP 8.1, 8.2, and 8.3 using the workflow in `.github/workflows/ci.yml`. The pipeline executes formatting checks, static analysis, and PHPUnit.

Contributing
------------

[](#contributing)

Open a focused pull request with a clear summary, test evidence, and notes about any behavior changes. Follow the repository conventions in `AGENTS.md`, keep examples framework-agnostic, and avoid introducing optional integrations as hard runtime dependencies.

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance90

Actively maintained with recent releases

Popularity18

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity45

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

Every ~25 days

Total

3

Last Release

45d 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 (14 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

[sentry/sentry

PHP SDK for Sentry (http://sentry.io)

1.9k247.1M334](/packages/sentry-sentry)[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)
