ldubois / cake-bugsnag
CakePHP4 的 bugsnag 插件
1.1.0
2022-06-20 14:49 UTC
Requires
- php: ^7
- bugsnag/bugsnag: ^3.0
- cakephp/cakephp: ^4.0
Requires (Dev)
- cakephp/cakephp-codesniffer: ^3.0
- jangregor/phpstan-prophecy: *
- phpstan/phpstan: @stable
- phpunit/phpunit: ^8.0
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