PHPackages                             compono-kit/sentry-client - 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-client

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

compono-kit/sentry-client
=========================

Sentry client with interface

1.0.0(today)00proprietaryPHPPHP &gt;=8.1

Since Jun 22Pushed todayCompare

[ Source](https://github.com/compono-kit/sentry-client)[ Packagist](https://packagist.org/packages/compono-kit/sentry-client)[ RSS](/packages/compono-kit-sentry-client/feed)WikiDiscussions main Synced today

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

SentryClient
============

[](#sentryclient)

Thin wrapper around the [Sentry PHP SDK](https://github.com/getsentry/sentry-php) with a clean interface, typed value objects, and a `NullSentryClient` for environments where Sentry is disabled.

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

[](#installation)

```
composer require compono-kit/sentry-client
```

Quick start
-----------

[](#quick-start)

```
use ComponoKit\SentryClient\SentryClient;
use ComponoKit\SentryClient\SentryClientConfig;

$client = new SentryClient(new SentryClientConfig([
    'dsn'             => 'https://key@o123.ingest.sentry.io/456',
    'environment'     => 'production',
    'release'         => 'my-app@2.1.0',
    'error-reporting' => E_ALL,
    'display-errors'  => false,
]));

$client->install(); // applies error_reporting + display_errors
```

Dependency injection
--------------------

[](#dependency-injection)

Depend on the interface, not the concrete class:

```
use ComponoKit\SentryClient\Interfaces\InformsSentry;

class OrderService
{
    public function __construct(private InformsSentry $sentry) {}

    public function place(Order $order): void
    {
        try {
            // ...
        } catch (\Throwable $exception) {
            $this->sentry->captureException($exception);
            throw $exception;
        }
    }
}
```

In tests or CLI tools where Sentry should be silent, pass a `NullSentryClient` instead:

```
use ComponoKit\SentryClient\NullSentryClient;

$service = new OrderService(new NullSentryClient());
```

---

Capturing events
----------------

[](#capturing-events)

### Exception

[](#exception)

```
use ComponoKit\SentryClient\Models\Types\Severity;

$client->captureException($exception);

// with severity
$client->captureException($exception, Severity::fatal());
```

### Message

[](#message)

```
use ComponoKit\SentryClient\Models\Types\Message;
use ComponoKit\SentryClient\Models\Types\Severity;

$client->captureMessage(new Message('Queue depth exceeded threshold'), Severity::warning());
```

### Last PHP error

[](#last-php-error)

```
@file_get_contents('/missing/file');

$client->captureLastError();                       // severity defaults to error
$client->captureLastError(Severity::warning());
```

---

Enriching events
----------------

[](#enriching-events)

### Tags

[](#tags)

Tags are global — they appear on every event sent after `useTags()` is called.

```
use ComponoKit\SentryClient\Models\Tags;

$client->useTags(Tags::fromKeyValueArray([
    'app'     => 'checkout-service',
    'version' => '2.1.0',
]));
```

### User

[](#user)

Like tags, the user context sticks until changed.

```
use ComponoKit\SentryClient\Models\User;

$client->setUser(new User(
    id:        (string) $user->id,
    email:     $user->email,
    username:  $user->name,
));
```

### Context

[](#context)

Context is per-event — it does not leak into subsequent captures.

```
use ComponoKit\SentryClient\Models\Context;
use ComponoKit\SentryClient\Models\ContextEntry;
use ComponoKit\SentryClient\Models\ContextGroup;

$context = new Context([
    new ContextGroup('order', [
        new ContextEntry('id',     '#1042'),
        new ContextEntry('amount', '149.90 EUR'),
    ]),
]);

$client->captureException($exception, Severity::error(), $context);
$client->captureMessage(new Message('Payment declined'), Severity::warning(), $context);
```

You can also build context from a plain array:

```
$context = Context::fromKeyValueArray([
    'order'   => ['id' => '#1042', 'amount' => '149.90 EUR'],
    'payment' => ['provider' => 'stripe', 'status' => 'declined'],
]);
```

### Breadcrumbs

[](#breadcrumbs)

Breadcrumbs recorded before a capture appear as a trail in the Sentry issue.

```
use ComponoKit\SentryClient\Models\Breadcrumb;

$client->addBreadcrumb(new Breadcrumb('User clicked checkout',    'ui',   'info'));
$client->addBreadcrumb(new Breadcrumb('Sending payment request',  'http', 'debug', ['url' => '/pay']));
$client->addBreadcrumb(new Breadcrumb('Payment gateway timeout',  'http', 'error'));

$client->captureException($exception);
```

`Breadcrumb` signature: `(message, category = 'default', level = 'info', data = [])`

### Fingerprint

[](#fingerprint)

Controls how Sentry groups events. Two events with the same fingerprint become one issue.

```
use ComponoKit\SentryClient\Models\Fingerprint;

$client->captureException(
    $exception,
    Severity::error(),
    null,
    new Fingerprint('PaymentService', 'timeout'),
);
```

---

Custom config via interface
---------------------------

[](#custom-config-via-interface)

Implement `ConfiguresSentryClient` to load credentials from any source (env vars, config files, secrets manager, …):

```
use ComponoKit\SentryClient\Interfaces\ConfiguresSentryClient;
use ComponoKit\SentryClient\Models\Types\Dsn;
use ComponoKit\SentryClient\Models\Types\Environment;
use ComponoKit\SentryClient\Models\Types\Release;

class EnvSentryConfig implements ConfiguresSentryClient
{
    public function getDsn(): Dsn                   { return new Dsn($_ENV['SENTRY_DSN']); }
    public function getEnvironment(): Environment   { return new Environment($_ENV['APP_ENV']); }
    public function getRelease(): Release           { return new Release($_ENV['APP_VERSION']); }
    public function getErrorReporting(): int        { return E_ALL; }
    public function shouldDisplayErrors(): bool     { return false; }
    public function getExtraOptions(): array        { return []; }
}
```

### Extra SDK options

[](#extra-sdk-options)

Pass any [Sentry PHP SDK option](https://docs.sentry.io/platforms/php/configuration/options/) via `extra-options` (or `getExtraOptions()`):

```
new SentryClientConfig([
    // ...required keys...
    'extra-options' => [
        'traces_sample_rate' => 0.2,
        'before_send'        => function (\Sentry\Event $event): ?\Sentry\Event {
            // drop events from bots
            if (str_contains((string) $event->getRequest()?->getHeaders()['User-Agent'] ?? '', 'bot')) {
                return null;
            }
            return $event;
        },
    ],
]);
```

---

Running tests
-------------

[](#running-tests)

```
composer test
```

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance100

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community2

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

0d 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-client/health.svg)

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

###  Alternatives

[sentry/sentry-laravel

Laravel SDK for Sentry (https://sentry.io)

1.3k122.6M185](/packages/sentry-sentry-laravel)[sentry/sentry-symfony

Symfony integration for Sentry (http://getsentry.com)

73764.5M84](/packages/sentry-sentry-symfony)[sentry/sdk

This is a meta package of sentry/sentry. We recommend using sentry/sentry directly.

327137.6M163](/packages/sentry-sdk)[stayallive/wp-sentry

A (unofficial) WordPress plugin to report PHP and JavaScript errors to Sentry.

383211.1k](/packages/stayallive-wp-sentry)[justbetter/magento2-sentry

Magento 2 Logger for Sentry

1861.5M3](/packages/justbetter-magento2-sentry)[networkteam/sentry-client

A Sentry client for TYPO3. It forwards errors and exceptions to Sentry - https://sentry.io/

391.1M6](/packages/networkteam-sentry-client)

PHPackages © 2026

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