0.0.27 2024-03-12 08:14 UTC

README

安装

安装 streply/streply-laravel

composer require streply/streply-laravel

将服务提供者添加到 config/app.php 配置文件中

此步骤仅适用于低于 11.X 版本的 Laravel。

Streply\Laravel\ServiceProvider::class,

启用异常捕获

Laravel 11.X

在 bootstrap/app.php 中启用异常捕获

<?php

use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;

return Application::configure(basePath: dirname(__DIR__))
    ->withRouting(
        web: __DIR__.'/../routes/web.php',
        commands: __DIR__.'/../routes/console.php',
        health: '/up',
    )
    ->withMiddleware(function (Middleware $middleware) {
        //
    })
    ->withExceptions(function (Exceptions $exceptions) {
        $exceptions->reportable(static function (Throwable $exception) {
            \Streply\Exception($exception);
        });
    })->create();

Laravel 8.x, 9.x 和 10.x

在 App/Exceptions/Handler.php 中启用异常捕获

<?php

public function register()
{
    $this->reportable(function (Throwable $e) {
        try {
            \Streply\Exception($e);
        } catch(\Exception $e) {}
    });
}

配置

使用此命令配置 Streply DSN

php artisan streply:publish https://clientPublicKey@api.streply.com/projectId