dbannik/sentry-symfony
Composer 安装命令:
composer require dbannik/sentry-symfony
包简介
Symfony integration for Sentry (http://getsentry.com)
README 文档
README
Bad software is everywhere, and we're tired of it. Sentry is on a mission to help developers write better software faster, so we can get back to enjoying technology. If you want to join us Check out our open positions
Official Sentry SDK for Symfony
This is the official Symfony SDK for Sentry.
Getting Started
Using this sentry-symfony SDK provides you with the following benefits:
- Quickly integrate and configure Sentry for your Symfony app
- Out of the box, each event will contain the following data by default
- The currently authenticated user
- The Symfony environment
Install
To install the SDK you will need to be using Composer in your project. To install it please see the docs.
composer require sentry/sentry-symfony
If you're using the Symfony Flex Composer plugin, you might encounter a message similar to this:
The recipe for this package comes from the "contrib" repository, which is open to community contributions.
Review the recipe at https://github.com/symfony/recipes-contrib/tree/master/sentry/sentry-symfony/3.0
Do you want to execute this recipe?
Just type y, press return, and the procedure will continue.
Caution: Due to a bug in the SensioFrameworkExtra bundle, affecting version 6.0 and below, you might run into a missing Nyholm\Psr7\Factory\Psr17Factory::class error while executing the commands mentioned above.
If you are not using the PSR-7 bridge, you can work around this issue by changing the configuration of the bundle as follows:
sensio_framework_extra: psr_message: enabled: false
For more details about the issue see sensiolabs/SensioFrameworkExtraBundle#710.
Enable the Bundle
If you installed the package using the Flex recipe, the bundle will be automatically enabled. Otherwise, enable it by adding it to the list
of registered bundles in the Kernel.php file of your project:
class AppKernel extends \Symfony\Component\HttpKernel\Kernel { public function registerBundles(): array { return [ // ... new \Sentry\SentryBundle\SentryBundle(), ]; } // ... }
The bundle will be enabled in all environments by default. To enable event reporting, you'll need to add a DSN (see the next step).
Configure
Add the Sentry DSN of your project.
If you're using Symfony 3.4, add the DSN to your app/config/config_prod.yml file.
For Symfony 4 or newer, add the DSN to your config/packages/sentry.yaml file.
Keep in mind that by leaving the dsn value empty (or undeclared), you will disable Sentry's event reporting.
sentry: dsn: "https://public:secret@sentry.example.com/1" messenger: enabled: true # flushes Sentry messages at the end of each message handling capture_soft_fails: true # captures exceptions marked for retry too options: environment: '%kernel.environment%' release: '%env(VERSION)%' #your app version
The parameter options allows to fine-tune exceptions. To discover more options, please refer to
the Unified APIs options and
the PHP specific ones.
Optional: use custom HTTP factory/transport
Since the SDK 2.0 uses HTTPlug to remain transport-agnostic, you need to install two packages that provide
php-http/async-client-implementation
and psr/http-message-implementation.
This bundle depends on sentry/sdk, which is a metapackage that already solves this need, requiring our suggested HTTP
packages: the Symfony HTTP client (symfony/http-client) and Guzzle's message factories (http-interop/http-factory-guzzle).
If you want to use a different HTTP client or message factory, you can override the sentry/sdk package by adding the following to your composer.json after the require section:
"replace": { "sentry/sdk": "*" }
For example when you want to use Guzzle's components:
composer require php-http/guzzle6-adapter guzzlehttp/psr7
If you don't have a compatible HTTP client and/or message factory implementation installed php-http/discovery will try to install it for you using a Composer plugin.
Maintained versions
- 4.x is actively maintained and developed on the master branch, and uses Sentry SDK 3.0;
- 3.x is supported only for fixes and uses Sentry SDK 2.0;
- 2.x is no longer maintained; from this version onwards it requires Symfony 3+ and PHP 7.1+;
- 1.x is no longer maintained; you can use it for Symfony < 2.8 and PHP 5.6/7.0;
- 0.8.x is no longer maintained.
Upgrading to 4.0
The 4.0 version of the bundle uses the newest version (3.x) of the underlying Sentry SDK. If you need to migrate from previous versions, please check the UPGRADE-4.0.md document.
Custom serializers
The option class_serializers can be used to send customized objects serialization.
sentry: options: class_serializers: YourValueObject: 'ValueObjectSerializer'
Several serializers can be added and the serializable check is done by using the instanceof type operator.
The serializer must implement the __invoke method, which needs to return an array, containing the information that should be send to Sentry. The class name is always sent by default.
Serializer example:
final class ValueObjectSerializer { public function __invoke(YourValueObject $vo): array { return [ 'value' => $vo->value() ]; } }
Contributing to the SDK
Please refer to CONTRIBUTING.md.
Getting help/support
If you need help setting up or configuring the Symfony SDK (or anything else in the Sentry universe) please head over to the Sentry Community on Discord. There is a ton of great people in our Discord community ready to help you!
Resources
License
Licensed under the MIT license, see LICENSE
dbannik/sentry-symfony 适用场景与选型建议
dbannik/sentry-symfony 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 06 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「logging」 「symfony」 「errors」 「sentry」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 dbannik/sentry-symfony 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dbannik/sentry-symfony 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 dbannik/sentry-symfony 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The bundle for easy using json-rpc api on your project
A Zend Framework module that sets up Monolog for logging in applications.
Bootstraps errors and handles them via reporters and renderers
Asynchronous Sentry for Symfony - Fire and forget
Stackdriver handler for Monolog (codeinternetapplications/monolog-stackdriver Fork).
High-performance, zero-dependency PSR-3 logger for MonkeysLegion with structured logging, handlers, processors, and PHP 8.4 features.
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-04