dkx / google-report-error-exception-writer
此包已被弃用且不再维护。未建议替代包。
Google ErrorReporting 库的包装器
1.0.0
2019-11-02 13:49 UTC
Requires
- php: >=7.3
- google/cloud-error-reporting: ^0.15.0
- psr/http-message: ^1.0
Requires (Dev)
- mockery/mockery: ^1.2
- phpstan/extension-installer: >=1.0
- phpstan/phpstan: >=0.11
- phpstan/phpstan-strict-rules: >=0.11
This package is auto-updated.
Last update: 2024-01-29 03:41:40 UTC
README
Google ErrorReporting 库的包装器
安装说明
$ composer require dkx/google-report-error-exception-writer
用法
<?php
namespace MyApp;
use DKX\GoogleReportErrorExceptionWriter\ReportErrorExceptionWriter;
use Google\Cloud\ErrorReporting\V1beta1\ReportErrorsServiceClient;
$googleProjectId = 'google-project-id';
$projectName = 'my-app/production';
$projectVersion = '0.0.1';
$client = new ReportErrorsServiceClient();
$writer = new ReportErrorExceptionWriter($client, $googleProjectId, $projectName, $projectVersion);
try {
buggy_code();
} catch (\Throwable $e) {
$writer->writeException($e);
}
如果你使用 PSR7 进行 HTTP,当前 HTTP 请求可以存储在错误上下文中。
<?php
$responseStatusCode = 500;
$writer->writeException($e, $httpRequest, $responseStatusCode);