arueckauer / mezzio-sentry-delegator
Mezzio Delegator and ErrorListener for Sentry
Installs: 16 236
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 2
Requires
- php: ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0
- ext-curl: *
- laminas/laminas-servicemanager: ^3.22 || ^4.2
- laminas/laminas-stratigility: ^3.12 || ^4.0
- sentry/sentry: ^4.0
Requires (Dev)
- ergebnis/composer-normalize: ~2.45.0
- laminas/laminas-coding-standard: ~3.0.1
- phpunit/phpunit: ~10.5.45
- rector/rector: ~2.0.9
- roave/security-advisories: dev-latest
- vimeo/psalm: ~6.7.1
README
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.
Installation
Via Composer
composer require arueckauer/mezzio-sentry-delegator
Configuration
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>', ], ];
Initialize Sentry
To initialize Sentry, add the following line to the anonymous function in public/index.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 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, ], ], ], ]; } }