aminin/airbrake-bundle

Symfony 3/4/5 的 Airbrake API v3 集成

安装次数: 55,843

依赖者: 0

建议者: 0

安全性: 0

星标: 8

关注者: 2

分支: 9

开放性问题: 2

类型:symfony-bundle

v0.6.0 2022-05-06 21:55 UTC

This package is not auto-updated.

Last update: 2024-09-21 23:30:42 UTC


README

Build Status Coding Style Latest Stable Version Total Downloads Latest Unstable Version SensioLabsInsight License

Airbrake.io & Errbit 的集成,支持 Symfony 3/4/5。此包将 Airbrake API 客户端 集成到 Symfony 项目中。

先决条件

本包版本需要 Symfony 3.4+ 和 php 7.2+

安装

步骤 1: 使用 composer 下载 AmiAirbrakeBundle

在 composer.json 中添加 AmiAirbrakeBundle

$ composer require aminin/airbrake-bundle

步骤 2: 启用包

在 kernel 中启用包

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Ami\AirbrakeBundle\AmiAirbrakeBundle(),
    );
}

步骤 3: 配置 AmiAirbrakeBundle

将以下配置添加到您的 config.yml 文件中

# app/config/config.yml
ami_airbrake:
    project_id:  YOUR-PROJECT-ID
    project_key: YOUR-API-KEY

配置参考

ami_airbrake:
    # This parameter is required
    # For Errbit the exact value of project_id doesn't matter
    project_id: YOUR-PROJECT-ID

    # Omit this key if you need to enable/disable the bundle temporarily 
    # If not given, this bundle will ignore all exceptions and won't send any data to remote.
    project_key: YOUR-API-KEY

    # By default, it is set to api.airbrake.io.
    # A host is a web address containing a scheme ("http" or "https"), a host and a port.
    # You can omit the scheme ("https" will be assumed) and the port (80 or 443 will be assumed).
    host: http://errbit.localhost:8000

    # You might want to ignore some exceptions such as http not found, access denied etc.
    # By default this bundle ignores all HttpException instances. (includes HttpNotFoundException, AccessDeniedException)
    # To log all exceptions leave this array empty.
    ignored_exceptions: ["Symfony\Component\HttpKernel\Exception\HttpException"]

parameters:
  # You may modify these parameters at your own risk
  ami_airbrake.notifier.class: 'Airbrake\Notifier'
  ami_airbrake.exception_listener.class: 'Ami\AirbrakeBundle\EventListener\ExceptionListener'
  ami_airbrake.shutdown_listener.class: 'Ami\AirbrakeBundle\EventListener\ShutdownListener'

用法

配置完成后,包将自动将异常/错误发送到 airbrake 服务器。

您可以通过 ami_airbrake.notifier 服务访问 Notifier

    /** @var ContainerInterface $container */
    $container->get('ami_airbrake.notifier')->addFilter(function ($notice) {
        $notice['context']['environment'] = 'production';
        return $notice;
    });

许可证

此包遵循 MIT 许可证。完整许可证请参阅 Resources/meta/LICENSE

参考

Airbrake API 客户端: https://github.com/airbrake/phpbrake