PHPackages                             compono-kit/sentry-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. compono-kit/sentry-error-handler

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

compono-kit/sentry-error-handler
================================

Error handler implementation of sentry

1.0.0(1mo ago)011proprietaryPHPPHP &gt;=8.1

Since Jun 23Pushed 1mo agoCompare

[ Source](https://github.com/compono-kit/sentry-error-handler)[ Packagist](https://packagist.org/packages/compono-kit/sentry-error-handler)[ RSS](/packages/compono-kit-sentry-error-handler/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (1)

SentryErrorHandler
==================

[](#sentryerrorhandler)

A `HandlesErrors` implementation that forwards messages and exceptions to Sentry via the `compono-kit/sentry-client` package.

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

[](#installation)

```
composer require compono-kit/sentry-error-handler
```

Setup
-----

[](#setup)

Create a `SentryClient` with a `SentryClientConfig` and pass it to `SentryErrorHandler`. Call `install()` once at application bootstrap to apply error reporting settings.

```
use ComponoKit\SentryClient\SentryClient;
use ComponoKit\SentryClient\SentryClientConfig;
use ComponoKit\ErrorHandlers\Sentry\SentryErrorHandler;

$client = new SentryClient(new SentryClientConfig([
    'dsn'              => 'https://your-dsn@sentry.io/123',
    'environment'      => 'production',
    'release'          => '1.4.2',
    'error-reporting'  => E_ALL,
    'display-errors'   => false,
]));

$handler = new SentryErrorHandler($client);
$handler->install();
```

Reporting errors
----------------

[](#reporting-errors)

### Exceptions

[](#exceptions)

```
try {
    $order->process();
} catch (\Throwable $exception) {
    // Default message: "RuntimeException occurred"
    $handler->exception($exception);

    // Custom message
    $handler->exception($exception, 'Order processing failed');
}
```

The exception's message, file, line, and stack trace are automatically attached as context.

### Severity levels

[](#severity-levels)

```
$handler->warning('Retry limit almost reached');
$handler->error('Payment gateway returned unexpected status');
$handler->critical('Database connection lost');
$handler->alert('Disk space below 5 %');
$handler->emergency('Service is completely unavailable');
```

Context
-------

[](#context)

Pass a flat array for simple key/value details, or a nested array to group entries into named sections.

```
// Flat — all entries appear under "Details"
$handler->error('Invalid checkout state', [
    'order_id' => '4711',
    'status'   => 'pending',
]);

// Grouped — each key becomes its own section in Sentry
$handler->error('Payment failed', [
    'Order'   => ['id' => '4711', 'total' => '99.00'],
    'Payment' => ['provider' => 'stripe', 'code' => 'card_declined'],
]);

// Mixed — scalar values land in "Details", arrays become named groups
$handler->error('Checkout aborted', [
    'user_id' => '42',
    'Cart'    => ['items' => '3', 'total' => '29.99'],
]);
```

Context has a maximum depth of two levels. Nesting arrays inside a group throws a `\LogicException`.

Tags
----

[](#tags)

Tags are indexed in Sentry and can be used to filter and search events.

```
$handler->warning('Cache miss rate elevated', context: [], tags: [
    'region'      => 'eu-west-1',
    'environment' => 'production',
]);

// Tags work on all severity methods
$handler->exception($exception, tags: ['team' => 'checkout']);
```

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance90

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

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

45d ago

### Community

Maintainers

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/compono-kit-sentry-error-handler/health.svg)

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

###  Alternatives

[psr/log

Common interface for logging libraries

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

API for OpenTelemetry PHP.

2044.7M332](/packages/open-telemetry-api)[open-telemetry/sdk

SDK for OpenTelemetry PHP.

2430.8M412](/packages/open-telemetry-sdk)

PHPackages © 2026

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