wodcz/nette-sentry-bridge
Composer 安装命令:
composer require wodcz/nette-sentry-bridge
包简介
Bridge that adds some framework-specific context to official Sentry PHP SDK client.
README 文档
README
Bridge that adds some framework-specific context to official Sentry PHP SDK client.
Installation and usage
Installation via composer:
composer require wodcz/nette-sentry-bridge
Usage
This is not usual extension that you would register in extensions: section of your config.neon.
In my opinion that is too late (something bad can happen before DIC is initialized).
Because of this, setup is a bit different.
app/bootstrap.php:
<?php declare(strict_types=1); require __DIR__ . '/../vendor/autoload.php'; $configurator = new Nette\Configurator; //$configurator->setDebugMode('23.75.345.200'); // enable for your remote IP $configurator->enableTracy(__DIR__ . '/../log'); $configurator->setTimeZone('Europe/Prague'); $configurator->setTempDirectory(__DIR__ . '/../temp'); $configurator->createRobotLoader() ->addDirectory(__DIR__) ->register(); $configurator->addConfig(__DIR__ . '/config/config.neon'); $configurator->addConfig(__DIR__ . '/config/config.local.neon'); ####################################### PART 1 ####################################### # Try to load configuration from app/config/sentry.php file if(is_array($config = (@include __DIR__ . '/config/sentry.php')) && @$config['dsn']){ $logger = new \wodCZ\NetteSentryBridge\SentryLogger($config['dsn'], @$config['options'] ?: []); } ####################################### PART 1 ####################################### $container = $configurator->createContainer(); ####################################### PART 2 ####################################### # Add container instance to logger, so it can pull some info from there. if (isset($logger)) { $logger->setContainer($container); } ####################################### PART 2 ####################################### return $container;
Then, create app/config/sentry.php with following configuration:
app/config/sentry.php:
<?php return [ 'dsn' => 'http://key:secret@sentry.example.com/123', 'options' => [ 'app_path' => __DIR__.'/../', 'environment' => 'production', 'exclude' => [ 'Nette\Application\BadRequestException', 'Nette\Application\ForbiddenRequestException', 'Nette\Application\AbortException' ], # 'revision' => '', # all options: https://docs.sentry.io/clients/php/config/ ] ];
Alternative configuration if you use docker or other setup that uses environment variables. If you don't specify dsn variable, extension will silently do nothing.
app/config/sentry.php:
<?php return [ 'dsn' => getenv('SENTRY_DSN'), 'options' => [ 'app_path' => __DIR__.'/../', 'environment' => getenv('DEBUG') === 'true' ? 'development' : 'production', 'exclude' => [ 'Nette\Application\BadRequestException', 'Nette\Application\ForbiddenRequestException', 'Nette\Application\AbortException' ], # 'revision' => '', # all options: https://docs.sentry.io/clients/php/config/ ] ];
This is just a sample, all you need to do is to create instance of \wodCZ\NetteSentryBridge\SentryLogger
to start logging, and call $logger->setContainer($container) to extend logs with Nette Context
and to log errors caught by Nette\Application
Important note to prevent confusion
Extension will not log anything if you have tracy enabled.
wodcz/nette-sentry-bridge 适用场景与选型建议
wodcz/nette-sentry-bridge 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 23.72k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 10 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「nette」 「sentry」 「raven」 「tracy」 「debbuger」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 wodcz/nette-sentry-bridge 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 wodcz/nette-sentry-bridge 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 wodcz/nette-sentry-bridge 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Raven client for Sentry that supports background processing through multiple providers.
A Yii2 client for Sentry (http://getsentry.com)
Fork of a PHP client for Sentry (http://getsentry.com) that work also with php5.2
An implementation of the Sentry User Manager for Laravel.
Sentry (Raven) error monitoring for Laravel and Lumen with send in background via queues
Display sentry event ids on error pages
统计信息
- 总下载量: 23.72k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2017-10-05