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.
Via Composer
composer require arueckauer/mezzio-sentry-delegator
Provide a dsn for Sentry and possible other configuration options in the project's configuration, e.g. config/autoload/services.local.php
. Go to the PHP configure documentation to select the dsn for a project.
<?php
declare(strict_types = 1);
use Sentry\Options as SentryOptions;
return [
// [..]
SentryOptions::class => [
'dsn' => 'https://<key>@<account-id>.ingest.sentry.io/<project-id>',
],
];
To initialize Sentry, add the following line to the anonymous function in public/index.php
.
(new MezzioSentryDelegator\SentryInitializer())($container);
Declare the delegator dependency in the project's configuration, e.g. config/autoload/dependencies.global.php
.
<?php
declare(strict_types = 1);
use MezzioSentryDelegator\Delegator;
use Laminas\Stratigility\Middleware\ErrorHandler;
class ConfigProvider
{
public function __invoke() : array
{
return [
'dependencies' => [
'delegators' => [
ErrorHandler::class => [
Delegator::class,
],
],
],
];
}
}