rabbit-digital / bugtify-laravel
Laravel 的错误监控、报告和错误通知器
v0.4
2023-10-31 05:09 UTC
Requires
- php: >=5.5
Requires (Dev)
- phpunit/phpunit: ^9.5
README
什么是 Bugtify?
此包允许您通过 webhook 将错误日志发送到 Discord。允许您跟踪您的 Laravel 应用程序中的任何错误
Laravel 上的安装
Bugtify 可以通过 Composer 安装。运行此命令
composer require rabbit-digital/bugtify-laravel
在 config/app.php
中的 providers 数组中注册我们的服务提供者,在 AppServiceProvider::class
之前
'providers' => [ // ... RabbitDigital\Bugtify\BugtifyServiceProvider::class, // ... ],
您只需发布包的配置文件。
php artisan vendor:publish --provider="RabbitDigital\Bugtify\BugtifyServiceProvider" --tag=config
在您的 .env 文件中配置 Discord Webhook URL
BUGTIFY_DISCORD_WEBHOOK=your-discord-webhook-here
如果您需要避免发送重复的错误通知,可以配置以下选项
BUGTIFY_LIMIT_ENABLED=true
Lumen 上的安装
Bugtify 可以通过 Composer 安装。运行此命令
composer require rabbit-digital/bugtify-laravel
将配置文件(bugtify.php)复制到 Lumen 配置目录。
php -r "file_exists('config/') || mkdir('config/'); copy('vendor/rabbit-digital/bugtify-laravel/config/bugtify.php', 'config/bugtify.php');"
然后根据您的需求调整配置文件(config/bugtify.php)。
在 bootstrap/app.php 中,您需要
取消注释此行,如果您还没有这样做的话。
$app->withFacades();
注册 Bugtify 服务提供者
$app->register(RabbitDigital\Bugtify\BugtifyServiceProvider::class);
报告未处理的异常
为确保所有未处理的异常都发送到 Discord,请设置 Bugtify 日志通道并将其添加到 config/logging.php 中的日志堆栈中
'channels' => [ 'stack' => [ 'driver' => 'stack', // Add bugtify to the stack: 'channels' => ['single', 'bugtify'], ], // ... // Create a bugtify logging channel: 'bugtify' => [ 'driver' => 'bugtify', ], ],
Laravel 和 Lumen 版本低于 5.5
Laravel 和 Lumen 版本低于 5.5 不支持 Logger 类。需要手动在 App\Exception\Handler.php
中添加
public function report(Exception $e) { \RabbitDigital\Bugtify\Facades\Bugtify::notifyException($e); parent::report($e); }
报告已处理的异常
可以通过以下方式实现已处理异常的报告
try { // Add some error code here } catch (Exception $ex) { \RabbitDigital\Bugtify\Facades\Bugtify::notifyException($ex); }
许可证
Bugtify for Laravel 库是免费软件,在 MIT 许可证下发布。有关详细信息,请参阅 LICENSE。