absszero / laravel-stackdriver-error-reporting
Laravel 的 Stackdriver 错误报告
v1.8.0
2024-03-22 12:40 UTC
Requires
- php: >=5.5
- google/cloud-error-reporting: ^0.19
- illuminate/support: >=5.1
Requires (Dev)
- phpunit/phpunit: >=4.0
README
需求
Laravel 5.1
~ 11.x
安装
-
composer require absszero/laravel-stackdriver-error-reporting
-
此包提供包自动发现功能。
对于 5.5 版本之前的 Laravel,您需要在
config/app.php
中添加 ServiceProvider。<?php ... 'providers' => [ Absszero\ErrorReportingServiceProvider::class,
-
php artisan vendor:publish --provider="Absszero\ErrorReportingServiceProvider"
配置
-
获取具有
logging.logWriter
角色的服务账户凭证(文档) -
将密钥文件存储在您的项目目录中,并在
.env
中引用它,如下所示GOOGLE_APPLICATION_CREDENTIALS=/My_Authentication.json
-
对于 Laravel 11 及更高版本。编辑
bootstrap/app.php
。->withExceptions(function (Exceptions $exceptions) { $exceptions->report(function (\Throwable $e) { (new \Absszero\ErrorReporting)->report($e); });
-
对于 Laravel 10 及更低版本。编辑
app/Exceptions/Handler.php
。对于 Laravel 9 及更高版本。
<?php public function register() { $this->reportable(function (Throwable $e) { (new \Absszero\ErrorReporting)->report($e); }); }
对于 7 之前的 PHP 版本,将
\Throwable
替换为\Exception
。<?php public function report(\Throwable $exception) { parent::report($exception); if ($this->shouldReport($exception)) { (new \Absszero\ErrorReporting)->report($exception); } }
贡献
- 复制它!
- 创建您的功能分支:
git checkout -b my-new-feature
- 提交您的更改:
git commit -am '添加一些功能'
- 将分支推送到远程:
git push origin my-new-feature
- 提交拉取请求 :D
致谢
TODO:编写致谢
许可证
本项目受 MIT 许可证的许可 - 有关详细信息,请参阅 LICENSE 文件