PHP code example of kolakachi / laravel-error-explainer

1. Go to this page and download the library: Download kolakachi/laravel-error-explainer 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/ */

    

kolakachi / laravel-error-explainer example snippets


use Kolakachi\ErrorExplainer\Facades\ErrorExplainer;

try {
    $charge->process();
} catch (Throwable $e) {
    $explanation = ErrorExplainer::explain($e);

    return response()->view('errors.friendly', [
        'message' => $explanation?->userMessage ?? __('Something went wrong.'),
    ], 500);
}

use Kolakachi\ErrorExplainer\Facades\ErrorExplainer;
use Kolakachi\ErrorExplainer\Contracts\LlmDriver;

ErrorExplainer::llm()->extend('gemini', fn ($app) => new class implements LlmDriver {
    public function complete(string $systemPrompt, string $userPrompt): string
    {
        // your HTTP call here
    }
});

// config/error-explainer.php
'except' => [
    App\Exceptions\ExpectedApiException::class,
],