PHP code example of dakshraman / laravel-ai-debugger

1. Go to this page and download the library: Download dakshraman/laravel-ai-debugger 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/ */

    

dakshraman / laravel-ai-debugger example snippets


return [
    'driver'   => env('AI_DEBUGGER_DRIVER', 'claude'),
    'log_path' => env('AI_DEBUGGER_LOG_PATH', storage_path('logs/laravel.log')),
];

use AIDebugger;

$result = AIDebugger::analyze($exception->getMessage());

// $result = [
//   'root_cause' => '...',
//   'fix'        => '...',
//   'steps'      => [...],
// ]

use Illuminate\Support\Facades\Log;

public function register(): void
{
    $this->app->reportable(function (\Throwable $e) {
        Log::info('AI Debug Analysis', app('ai-debugger')->analyze($e->getMessage()));
    });
}

use Dakshraman\AIDebugger\AI\AIInterface;

class MyCustomDriver implements AIInterface
{
    public function analyze(string $input): string
    {
        // Call your AI tool and return the response string
        return shell_exec('echo ' . escapeshellarg($input) . ' | my-ai-tool');
    }
}
bash
php artisan vendor:publish --tag=config
bash
php artisan debug:analyze