Every Laravel developer has stared at a cryptic error message, googled it, tried three solutions, and finally found the answer on page 4 of a Stack Overflow thread. I got tired of this pattern and built laravel-ai-debugger.
The Problem
Laravel errors often come with context that's hard to parse:
TypeError: Illuminate\Database\Eloquent\Collection::toArray():
Argument #1 ($callback) must be of type ?Closure, array givenThe error alone doesn't tell you *where* in your code the issue originates, or *why* you're passing the wrong type. You need to trace back through your code to find the root cause.
The Solution
laravel-ai-debugger hooks into Laravel's exception handler and provides:
// Install and configure
composer require dakshraman/laravel-ai-debugger
php artisan vendor:publish --provider="Dakshraman\AiDebugger\AiDebuggerServiceProvider"How It Works Under the Hood
The tool uses a pipeline approach:
class DebuggerPipeline
{
public function handle($exception, Closure $next)
{
$context = $this->analyzer->analyze($exception);
$suggestion = $this->matcher->findSolution($context);
if ($suggestion) {
$this->output->suggest($suggestion);
}
return $next($exception);
}
}The analyzer reads the stack trace, identifies the file and line number, and pulls in surrounding code context. The matcher then compares this against a database of known Laravel patterns.
Lessons Learned
Results
Since launching, laravel-ai-debugger has:
The project is open source and contributions are welcome. Check it out on GitHub.