dkx/google-report-error-exception-writer

This package is abandoned and no longer maintained. No replacement package was suggested.

Wrapper for Google ErrorReporting library

1.0.0 2019-11-02 13:49 UTC

This package is auto-updated.

Last update: 2024-01-29 03:41:40 UTC


README

Wrapper for Google ErrorReporting library

Installation

$ composer require dkx/google-report-error-exception-writer

Usage

<?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);
}

Current HTTP request can be stored in the error context if you use PSR7 for HTTP:

<?php

$responseStatusCode = 500;
$writer->writeException($e, $httpRequest, $responseStatusCode);