samplemeapp/airbrake-bundle

PHP 7, Symfony 2.8+ bundle,用于将错误发送到 Airbrake

安装: 426

依赖项: 0

建议者: 0

安全: 0

星星: 0

关注者: 3

分支: 0

开放性问题: 0

类型:symfony-bundle

1.2.0 2016-12-14 11:48 UTC

This package is not auto-updated.

Last update: 2022-10-15 08:52:18 UTC


README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

我们的 Airbrake bundle 允许开发团队快速为 PHP7 包和基于 Symfony 2.8+ 的项目添加错误/异常报告功能,通过 airbrake.ioerrbit.com

该 bundle 支持多个自定义参数,PSR-4 自动加载,符合 PSR-2 标准,并通过自动化测试进行了充分的测试,同时也在 SampleMe 生态系统中的各种微服务中使用。

安装

通过 Composer

$ composer require samplemeapp/airbrake-bundle

app/AppKernel.php 中启用 bundle。

$bundles = [
    new SM\AirbrakeBundle\SMAirbrakeBundle(),
]

配置

为了将所有异常报告到 airbrake.io,请将以下配置添加到您的 app/config/config.yml

sm_airbrake:
    project_id: 'your-project-id'
    project_key: 'your-project-key'
    listener_enabled: true

使用

如果您想手动与 Airbrake 服务交互,它也作为容器服务公开

$exception = new \Exception('Something went wrong');
$container->get('sm_airbrake.airbrake.service')->notify($exception);

您可能想要遵循上述方法的用例之一是,如果您不希望监听器在每次异常时触发,或者您想在服务调用时添加自己的业务逻辑。

有关更多 API 信息,请参阅 SM\AirbrakeBundle\Service\AirbrakeService

配置参考

以下配置参数也适用于此 bundle

sm_airbrake:
    # The ID of the project.
    project_id: string #project-id
    
    # The key of the project.
    project_key: string #project-key
    
    # The HTTP client to use in order to contact the host.
    # Defaults to 'default'.
    http_client: string #default/curl/guzzle/
    
    # Whether or not to register a global exception instance, retrievable via Instance::notify($e);
    # Defaults to false.
    global_exception_instance: boolean #true/false
    
    # Whether or not to register a global error and exception handler.
    # Defaults to false.
    global_error_and_exception_handler: boolean #true/false
    
    # The host to which the bundle should connect.
    # Defaults to 'api.airbrake.io'.
    host: string #api.airbrake.io/errbit.internal
    
    # Exception class paths that should be ignored. Useful for not overloading your logs.
    # Defaults to [].
    ignored_exceptions:
        - "Symfony\\Component\\HttpKernel\\Exception\\HttpException"
        - "Symfony\\Component\\Security\\Core\\Exception\\AccessDeniedException"
        
    # The root directory that should be reported to the host
    # Defaults to the 'kernel.root_dir' parameter
    root_directory: string
    
    # The environment that should be reported to the host
    # Defaults to 'undefined'
    environment: string 
    
    # The app version that should be reported to the host
    # Defaults to 'undefined' or the value in the /VERSION file present in the root directory of the project.
    app_version: string
    
    # Enables or disables the 'kernel.exception' event listener.
    # Defaults to false.
    listener_enabled: boolean #true/false

测试

$ composer test

PSR-2 兼容性

$ composer check-styles
$ composer fix-styles

贡献

有关详细信息,请参阅 CONTRIBUTINGCONDUCT

安全

如果您发现任何与安全相关的问题,请通过电子邮件发送到 petre@dreamlabs.ro 而不是使用问题跟踪器。

鸣谢

许可

MIT 许可证 (MIT)。有关更多信息,请参阅 许可文件