geo6/zend-expressive-sentry

能够将错误发送到 Sentry.io 的 Zend Expressive ErrorHandler

v1.0.0 2019-08-20 07:24 UTC

This package is auto-updated.

Last update: 2024-09-21 02:09:59 UTC


README

Latest Stable Version Total Downloads Monthly Downloads Software License

此库使 Zend Expressive 能够将错误和异常发送到 Sentry.io

安装

composer require geo6/zend-expressive-sentry

配置

在您的 config 目录下创建一个 sentry.global.php 文件,并包含正确的 DSN(如果需要,还可以包含选项)

<?php

declare(strict_types=1);

return [
    'sentry' => [
        'dsn' => 'https://xxxxx@sentry.io/12345',
    ],
];

使用方法

要启用它,您只需将 Geo6\Expressive\Sentry\ConfigProvider::class 添加到主配置(通常是 config/config.php)中

...

$aggregator = new ConfigAggregator([
+     Geo6\Expressive\Sentry\ConfigProvider::class,
...
], $cacheConfig['config_cache_path']);

...

Sentry ErrorHandler 只在 "生产模式" 下(当 $config['debug']false 时)生效。
要切换到 "生产模式",您可以使用 composer run development-disable

此库受到 stickeeuk/zend-expressive-sentry 的启发。
主要区别在于此库使用最新的 PHP SDK