phpnomad/sentry-integration

Sentry error monitoring integration for PHPNomad

Maintainers

Package info

github.com/phpnomad/sentry-integration

pkg:composer/phpnomad/sentry-integration

Statistics

Installs: 335

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.3 2026-03-31 15:31 UTC

This package is auto-updated.

Last update: 2026-04-10 02:11:31 UTC


README

Latest Version Total Downloads PHP Version License

Integrates Sentry with PHPNomad's logging. A listener subscribes to ItemLogged events from phpnomad/core, forwards WARNING and above to Sentry as captured events, and records lower-severity entries as breadcrumbs so they appear as context on the next error. Severity mapping, capture rules, and DSN sourcing are all override points.

Installation

composer require phpnomad/sentry-integration

What this provides

  • A listener that forwards ItemLogged events to Sentry, with automatic severity mapping from PHPNomad log levels to Sentry severities.
  • A SentryCaptureGate interface with a default implementation that captures WARNING and above. Override it to change what becomes an event versus a breadcrumb.
  • A SentryDsnProvider interface so the host application supplies the DSN from its own configuration source (environment variables, secrets manager, config file).

Requirements

  • phpnomad/core (provides the ItemLogged event)
  • phpnomad/event and phpnomad/loader for listener registration
  • sentry/sentry ^4.0
  • PHP 8.2 or later

Usage

Implement SentryDsnProvider with your application's DSN source, bind it in an initializer, and register SentryInitializer in your loader chain.

use PHPNomad\Loader\Interfaces\HasClassDefinitions;
use PHPNomad\Sentry\Interfaces\SentryDsnProvider;

class EnvDsnProvider implements SentryDsnProvider
{
    public function getDsn(): string
    {
        return $_ENV['SENTRY_DSN'] ?? '';
    }
}

class AppSentryInitializer implements HasClassDefinitions
{
    public function getClassDefinitions(): array
    {
        return [EnvDsnProvider::class => SentryDsnProvider::class];
    }
}

Add SentryInitializer and AppSentryInitializer to your loader. From that point forward, any $logger->error() or $logger->critical() call is forwarded to Sentry without further application changes. If the DSN is empty the hub no-ops, and all Sentry calls are wrapped in try/catch so monitoring never crashes the host app.

Documentation

Framework docs live at phpnomad.com. For Sentry client configuration, see the Sentry PHP SDK documentation.

License

MIT. See LICENSE.