eo/airbrake-bundle

Airbrake.io 对 Symfony 的集成

安装次数: 54,233

依赖关系: 1

建议者: 0

安全: 0

星标: 6

关注者: 3

分支: 10

开放问题: 2

类型:symfony-bundle

v1.0.5 2016-10-26 16:56 UTC

This package is auto-updated.

Last update: 2024-08-24 00:11:45 UTC


README

Latest Stable Version Dependencies Status

Airbrake.ioErrbit 对 Symfony2 的集成。

先决条件

此版本的包需要 Symfony 2.1+

安装

步骤 1:使用 composer 下载 EoAirbrakeBundle

在您的 composer.json 中添加 EoAirbrakeBundle

{
    "require": {
        "eo/airbrake-bundle": "dev-master"
    }
}

现在运行以下命令,让 composer 下载包

$ php composer.phar update eo/airbrake-bundle

Composer 将将包安装到您的项目的 vendor/eo 目录。

步骤 2:启用包

在内核中启用包

<?php
// app/AppKernel.php

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

步骤 3:配置 EoAirbrakeBundle

现在您已正确安装并启用了 EoAirbrakeBundle,下一步是配置该包以与您的应用程序的具体需求一起工作。

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

# app/config/config.yml
eo_airbrake:
    api_key: YOUR-API-KEY

步骤 4(可选):添加 EoAirbrakeBundle 路由以模拟错误异常

如果您想模拟异常并测试您的配置,您可以在您的应用程序中添加以下路由。

# app/config/routing.yml
eo_airbrake_simulate:
    pattern: /airbrake/simulate
    defaults:  { _controller:  EoAirbrakeBundle:Simulate:index }

现在您可以从 http://domain.tld/airbrake/simulate 访问示例控制器。

配置参考

eo_airbrake:
    # 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.
    api_key: YOUR-API-KEY

    # By default, the notifier uses a socket connection to send the exceptions to Airbrake, 
    # which WON'T wait for a response back from the server. 
    # If this is not derisable for your application, you can pass async: false 
    # and the notifier will send an syncronous notification using cURL.
    async: true

    # If you are using your own hosted implementation of 
    # Airbrake (such as Errbit) you will have to specify your custom host name.
    host: errbit.example.com

    # 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"]

    # If you want to force override of whether or not to use SSL you can set secure to true/false whether or not to use SSL you can set secure to true/false
    # By default secure is set to true
    secure: true

用法

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

记录 JavaScript 错误

EoAirbrakeBundle 包含一个用于 airbrake JavaScript 通知器的 twig 扩展。为了在客户端开始记录异常,您必须将 {{ airbrake_notifier() }} 函数添加到您的基本模板中。

<!doctype html>
<html lang="en">
    <head>
        <title>Hello World</title>
        <!-- Airbrake notifier -->
        {{ airbrake_notifier() }}
    </head>
...

许可证

此包受 MIT 许可证的保护。请参阅包中的完整许可证。

Resources/meta/LICENSE

报告问题或功能请求

与该包相关的问题和功能请求在 Github 问题跟踪器中跟踪 https://github.com/eymengunay/EoAirbrakeBundle/issues