basecom / spryker-sentry
此包已被废弃且不再维护。未建议替换包。
用于在所有层中利用 sentry 进行 PHP 级别错误记录的 spryker 包
0.2.3
2021-10-06 12:42 UTC
Requires
- php: >=7.3.0
- phpstan/phpstan: ^0.12.99
- sentry/sdk: ^3.1
- spryker/error-handler: ^2.1.0
- spryker/kernel: ^3.30.0
- spryker/symfony: *
Requires (Dev)
- roave/security-advisories: dev-latest
- spryker/code-sniffer: ^0.16.4
This package is auto-updated.
Last update: 2024-07-11 17:48:48 UTC
README
用于在所有层中利用 sentry 进行 PHP 级别错误记录的 spryker 包
安装
通过 composer 安装
$ composer require basecom/spryker-sentry
集成
- 将 Basecom 添加到 config_default.php 中的命名空间
$config[KernelConstants::CORE_NAMESPACES][] = 'Basecom';
- 将相应的
SentryApplicationPlugin
添加到您想要将错误记录到 sentry 的每一层
Glue
将 SentryApplicationPlugin
添加到 Pyz\Glue\GlueApplication\GlueApplicationDependencyProvider
protected function getApplicationPlugins(): array
{
return [
...
new Basecom\Glue\Sentry\Plugin\Application\SentryApplicationPlugin(),
];
}
Zed
将 SentryApplicationPlugin
添加到 Pyz\Zed\Application\ApplicationDependencyProvider
protected function getApplicationPlugins(): array
{
return [
...
new Basecom\Zed\Sentry\Communication\Plugin\Application\SentryApplicationPlugin(),
];
}
Yves
将 SentryApplicationPlugin
添加到 Pyz\Yves\ShopApplication\ShopApplicationDependencyProvider
protected function getApplicationPlugins(): array
{
return [
...
new Basecom\Yves\Sentry\Plugin\Application\SentryApplicationPlugin(),
];
}
控制台 / CLI
将 SentryConsolePlugin
添加到 Pyz\Zed\Console\ConsoleDependencyProvider
public function getEventSubscriber(Container $container)
{
$eventSubscriber = parent::getEventSubscriber($container);
...
$eventSubscriber[] = new SentryConsolePlugin();
return $eventSubscriber;
}
配置
在 config_*.php 中配置 sentry 记录器
<?php
use Basecom\Shared\Sentry\SentryConstants;
...
// full sentry DSN. if empty, sentry logging is disabled in this config / environment
$config[SentryConstants::SENTRY_DSN] = 'https://###@###.ingest.sentry.io/###';
// set alternative environment names (per Layer), defaults to $APPLICATION_ENV when not set
$config[SentryConstants::SENTRY_ENVIRONMENT_ZED] = 'stage_zed';
$config[SentryConstants::SENTRY_ENVIRONMENT_GLUE] = 'stage_glue';
$config[SentryConstants::SENTRY_ENVIRONMENT_YVES] = 'stage_yves';
$config[SentryConstants::SENTRY_ENVIRONMENT_CONSOLE] = 'stage_console';
// error types which should be logged
$config[SentryConstants::SENTRY_ERROR_TYPES] = E_ALL ^ E_DEPRECATED ^ E_USER_DEPRECATED