PHPackages                             philiprehberger/php-exception-reporter - 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. philiprehberger/php-exception-reporter

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

philiprehberger/php-exception-reporter
======================================

Lightweight exception reporting to log channels and webhooks

v1.0.3(1mo ago)11[1 PRs](https://github.com/philiprehberger/php-exception-reporter/pulls)MITPHPPHP ^8.2CI passing

Since Mar 13Pushed 1mo agoCompare

[ Source](https://github.com/philiprehberger/php-exception-reporter)[ Packagist](https://packagist.org/packages/philiprehberger/php-exception-reporter)[ Docs](https://github.com/philiprehberger/php-exception-reporter)[ RSS](/packages/philiprehberger-php-exception-reporter/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (5)Used By (0)

PHP Exception Reporter
======================

[](#php-exception-reporter)

[![Tests](https://github.com/philiprehberger/php-exception-reporter/actions/workflows/tests.yml/badge.svg)](https://github.com/philiprehberger/php-exception-reporter/actions/workflows/tests.yml)[![Latest Version on Packagist](https://camo.githubusercontent.com/93a18191900d4ab41c322765041e35087c67679428fa8f3765cb7f4e578b582f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7068696c69707265686265726765722f7068702d657863657074696f6e2d7265706f727465722e737667)](https://packagist.org/packages/philiprehberger/php-exception-reporter)[![License](https://camo.githubusercontent.com/2360a708a44ad99e90ece0f99a69f309e1ebe1b6f5d27b82c259bf96d09f3d8d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7068696c69707265686265726765722f7068702d657863657074696f6e2d7265706f72746572)](LICENSE)

Lightweight exception reporting to log channels and webhooks.

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

[](#requirements)

- PHP 8.2+

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

[](#installation)

```
composer require philiprehberger/php-exception-reporter
```

Usage
-----

[](#usage)

### Basic reporting with a callback

[](#basic-reporting-with-a-callback)

```
use PhilipRehberger\ExceptionReporter\ExceptionReporter;
use PhilipRehberger\ExceptionReporter\Channels\CallbackChannel;

$reporter = new ExceptionReporter();

$reporter->addChannel(new CallbackChannel(function ($report) {
    error_log("[{$report->class}] {$report->message} in {$report->file}:{$report->line}");
}));

try {
    riskyOperation();
} catch (\Throwable $e) {
    $reporter->capture($e);
}
```

### File channel

[](#file-channel)

```
use PhilipRehberger\ExceptionReporter\Channels\FileChannel;

$reporter->addChannel(new FileChannel('/var/log/app-exceptions.log'));

// Each report is written as a JSON line
$reporter->capture(new \RuntimeException('Something failed'));
```

### Multiple channels

[](#multiple-channels)

```
$reporter
    ->addChannel(new CallbackChannel(function ($report) {
        // Send to your monitoring service
    }))
    ->addChannel(new FileChannel('/var/log/exceptions.log'));
```

### Deduplication

[](#deduplication)

Prevent the same exception (same class, file, and line) from being reported more than once:

```
$reporter->enableDeduplication();

$exception = new \RuntimeException('flaky');
$reporter->capture($exception); // Reported
$reporter->capture($exception); // Skipped (duplicate)

$reporter->resetFingerprints(); // Clear dedup state
$reporter->capture($exception); // Reported again
```

### Adding context

[](#adding-context)

```
$reporter->capture($exception, [
    'user_id' => 42,
    'request_url' => '/checkout',
]);
```

### Custom channels

[](#custom-channels)

Implement the `ReportChannel` interface to build your own channel:

```
use PhilipRehberger\ExceptionReporter\Contracts\ReportChannel;
use PhilipRehberger\ExceptionReporter\ExceptionReport;

class SlackChannel implements ReportChannel
{
    public function report(ExceptionReport $report): void
    {
        // POST to Slack webhook with $report->toArray()
    }
}
```

API
---

[](#api)

### `ExceptionReporter`

[](#exceptionreporter)

MethodDescription`addChannel(ReportChannel $channel): self`Register a reporting channel`enableDeduplication(): self`Enable fingerprint-based deduplication`capture(Throwable $e, array $context = []): ExceptionReport`Capture and report an exception`resetFingerprints(): void`Clear deduplication state### `ExceptionReport`

[](#exceptionreport)

Property / MethodDescription`string $class`Exception class name`string $message`Exception message`string $file`File where the exception was thrown`int $line`Line number`string $trace`Stack trace as string`DateTimeImmutable $timestamp`When the exception was captured`array $context`Additional context data`?string $previousClass`Previous exception class, if any`?string $previousMessage`Previous exception message, if any`fingerprint(): string`MD5 hash of class + file + line`toArray(): array`Serialize to array`fromThrowable(Throwable, array): self`Create from a throwable### Channels

[](#channels)

ChannelDescription`CallbackChannel`Invokes a user-provided callable`FileChannel`Appends JSON-encoded reports to a fileDevelopment
-----------

[](#development)

```
composer install
vendor/bin/phpunit
vendor/bin/pint --test
vendor/bin/phpstan analyse
```

License
-------

[](#license)

MIT

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance90

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

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 ~2 days

Total

4

Last Release

52d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cfd7d24cbbf32400fa13ce0bbe7a31edd2d66a6d4488eafdb3d64c5337bf0435?d=identicon)[philiprehberger](/maintainers/philiprehberger)

---

Top Contributors

[![philiprehberger](https://avatars.githubusercontent.com/u/8218077?v=4)](https://github.com/philiprehberger "philiprehberger (11 commits)")

---

Tags

loggingexceptionerrorreportingwebhook

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/philiprehberger-php-exception-reporter/health.svg)

```
[![Health](https://phpackages.com/badges/philiprehberger-php-exception-reporter/health.svg)](https://phpackages.com/packages/philiprehberger-php-exception-reporter)
```

###  Alternatives

[facade/flare-client-php

Send PHP errors to Flare

51899.9M4](/packages/facade-flare-client-php)[spatie/flare-client-php

Send PHP errors to Flare

177148.0M15](/packages/spatie-flare-client-php)[justbetter/magento2-sentry

Magento 2 Logger for Sentry

1851.5M3](/packages/justbetter-magento2-sentry)[phptek/sentry

Sentry.io integration for SilverStripe. Binds Sentry.io to SilverStripe's error &amp; exception handling subsystem.

15203.5k3](/packages/phptek-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)
