Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/arueckauer/mezzio-sentry-delegator

Mezzio Delegator and ErrorListener for Sentry
https://github.com/arueckauer/mezzio-sentry-delegator

mezzio sentry

Last synced: 2 months ago
JSON representation

Mezzio Delegator and ErrorListener for Sentry

Awesome Lists containing this project

README

        

# mezzio-sentry-delegator

Mezzio Delegator and ErrorListener for Sentry

This package provides an initialization wrapper for Sentry and the ability to capture Throwables in Sentry through an `ErrorListener` for the [Stratigility `ErrorHandler` middleware](https://docs.laminas.dev/laminas-stratigility/v3/error-handlers/#handling-php-errors-and-exceptions).

## Installation

Via Composer

```shell
composer require arueckauer/mezzio-sentry-delegator
```

## Configuration

Provide a dsn for Sentry and possible other [configuration options](https://docs.sentry.io/platforms/php/configuration/) in the project's configuration, e.g. `config/autoload/services.local.php`. Go to the [PHP configure documentation](https://docs.sentry.io/platforms/php/#configure) to select the dsn for a project.

```php
[
'dsn' => 'https://@.ingest.sentry.io/',
],
];

```

## Initialize Sentry

To initialize Sentry, add the following line to the anonymous function in `public/index.php`.

```php
(new MezzioSentryDelegator\SentryInitializer())($container);
```

## Attach Listener by wiring delegator

Declare the delegator dependency in the project's configuration, e.g. `config/autoload/dependencies.global.php`.

```php
[
'delegators' => [
ErrorHandler::class => [
Delegator::class,
],
],
],
];
}
}

```