PHP code example of engaging-io / issue-reporter

1. Go to this page and download the library: Download engaging-io/issue-reporter library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

engaging-io / issue-reporter example snippets


use EngagingIo\IssueReporter\Facades\IssueReporter;

try {
    // Your code that might throw an exception
} catch (\Throwable $e) {
    IssueReporter::report($e);

    // Then handle the exception as you normally would
}

// app/Exceptions/Handler.php

namespace App\Exceptions;

use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use EngagingIo\IssueReporter\Facades\IssueReporter;
use Throwable;

class Handler extends ExceptionHandler
{
    // ...

    public function report(Throwable $exception)
    {
        // You can add conditions to determine which exceptions to report
        if ($this->shouldReportToIssueReporter($exception)) {
            IssueReporter::report($exception);
        }

        parent::report($exception);
    }

    private function shouldReportToIssueReporter(Throwable $exception)
    {
        // Implement your logic to determine which exceptions to report
        return !$this->inExcludeList($exception) && app()->environment('production');
    }

    // ...
}

// bootstrap/app.php

use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use EngagingIo\IssueReporter\Facades\IssueReporter;
// ...

return Application::configure(basePath: dirname(__DIR__))
    // ...
    ->withExceptions(function (Exceptions $exceptions) {
        // This section captures all types of exceptions.
        $exceptions->reportable(fn (\Throwable $e) => IssueReporter::report($e));
    })->create();
bash
php artisan vendor:publish --provider="EngagingIo\IssueReporter\IssueReporterServiceProvider"