serbannasui/laravel-airbrake
Composer 安装命令:
composer require serbannasui/laravel-airbrake
包简介
Laravel service provider for Airbrake https://github.com/airbrake/phpbrake
README 文档
README
This is a Laravel service provider for the latest Airbrake PHP package https://github.com/airbrake/phpbrake
The service provider will configure an instance of Airbrake\Notifier with an ID, key and environment name.
Install
Require this package via composer.
composer require serbannasui/laravel-airbrake
For Laravel >=5.5 the package will be discoverd. For Laravel <=5.4 add package to list of service providers in config/app.php
<?php
//config/app.php
'providers' => [
Kouz\LaravelAirbrake\ServiceProvider::class,
],
Publish and fill out the config/airbrake.php file with your ID and key.
php artisan vendor:publish --provider="Kouz\LaravelAirbrake\ServiceProvider"
Config
The variables projectId and projectKey are required. Leave the rest empty to use Airbrake's default values.
'projectId' => '',
'projectKey' => '',
'environment' => env('APP_ENV', 'production'),
//leave the following options empty to use defaults
'host' => null, #airbrake api host e.g.: 'api.airbrake.io' or 'http://errbit.example.com
'appVersion' => null,
'revision' => null, #git revision
'rootDirectory' => null,
'keysBlacklist' => null, #list of keys containing sensitive information that must be filtered out
'httpClient' => null, #http client implementing GuzzleHttp\ClientInterface
Basic Usage
>=5.6 Custom Channel
Add the custom "airbrake" channel (outlined below) to config/logging.php. Then add the "airbrake" channel to the stack channel.
//config/logging.php
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => ['single', 'airbrake'],
],
'airbrake' => [
'driver' => 'custom',
'via' => Kouz\LaravelAirbrake\AirbrakeLogger::class,
'level' => 'error',
],
]
Exception Handler
To notify airbrake through the laravel exception handler as shown in the following code snippet. Inject or make a new instance of a Airbrake\Notifier object then pass a exception to the notify function.
//app/Exceptions/Handler.php
/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $exception
* @return void
*/
public function report(Exception $exception)
{
if ($this->shouldReport($exception) && App::environment(['production', 'staging'])) {
$airbrakeNotifier = \App::make('Airbrake\Notifier');
$airbrakeNotifier->notify($exception);
}
parent::report($exception);
}
<=5.5 Custom Monolog Configuration
To configure it as a Monolog handler you will have to create a custom configuration in bootstrap/app.php. This callback function is called before the service providers are loaded. So it is necessary to directly use our AirbrakeHandler class instead of the provider.
//bootstrap/app.php
$app->configureMonologUsing(function($monolog) use ($app) {
$airbrakeNotifier = (new Kouz\LaravelAirbrake\AirbrakeHandler($app))->handle();
$monologHandler = new Airbrake\MonologHandler($airbrakeNotifier, Monolog\Logger::ERROR);
$monolog->pushHandler($monologHandler);
});
serbannasui/laravel-airbrake 适用场景与选型建议
serbannasui/laravel-airbrake 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.59k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 07 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「airbrake」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 serbannasui/laravel-airbrake 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 serbannasui/laravel-airbrake 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 serbannasui/laravel-airbrake 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Airbrake.io integration for Symfony
Laravel package for the Airbrake API, which supports Errbit
errbit/airbrake integration with php with psr-2
Airbrake (phpbrake) integration for Zend Framework 3 (ZF3)
Yii2 PHPBrake integration
A PHP 5.3 library for sending errors to the Airbrake.io service.
统计信息
- 总下载量: 4.59k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-07-26