ldubois/cake-bugsnag

CakePHP4 的 bugsnag 插件

安装次数: 4,324

依赖关系: 0

推荐者: 0

安全性: 0

星标: 0

关注者: 1

分支: 1

公开问题: 0

类型:cakephp-plugin

1.1.0 2022-06-20 14:49 UTC

This package is auto-updated.

Last update: 2024-09-20 20:11:03 UTC


README

Bugsnag 的 CakePHP 集成。

需求

  • PHP 7.1+
  • CakePHP 4.0+
  • 以及 Bugsnag 账户

安装

使用 composer install.

composer require ldubois/cake-bugsnag

使用方法

设置配置文件。

填写您的 Bugsnag 账户信息。

// in `config/app.php`
return [
  'Bugsnag' => [
    'apiKey' => YOUR_Bugsnag_apiKey,
    'userId' => YOUR_SESSION_USER_ID,//default => Auth.User.id in Session
    'userName' => YOUR_SESSION_USER_NAME //default => Auth.User.name in Session
  ]
];

加载插件。

在 Application.php 中

public function bootstrap()
{
    parent::bootstrap();

    $this->addPlugin(\ldubois\Bugsnag\Plugin::class);
}

或者使用 cake 命令。

bin/cake plugin load ldubois/Bugsnag --bootstrap

这就完成了!🎉

高级使用

忽略嘈杂的异常

您可以过滤掉那些闹腾且难以确定要解决的问题的异常(如 PageNotFoundException)。设置异常不记录在 Error.skipLog

示例)

// in `config/app.php`
'Error' => [
    'skipLog' => [
        NotFoundException::class,
        MissingRouteException::class,
        MissingControllerException::class,
    ],
]

参考:CakePHP 烹饪书
https://book.cakephp.com.cn/4/en/development/errors.html#error-exception-configuration