Looking to hire Laravel developers? Try LaraJobs

laravel-watson maintained by alibori

Description
Laravel Watson watches your application's exceptions, uses the Laravel AI SDK to diagnose the likely cause and fix, and notifies you only when it's actually worth knowing about.
Last update
2026/11/18 15:09 (dev-main)
License
Downloads
0

Comments
comments powered by Disqus

Laravel Watson

Latest Version on Packagist Tests PHPStan Code Style Total Downloads

Laravel Watson watches your application's exceptions, uses the Laravel AI SDK to diagnose the likely cause and fix, and notifies you only when it's actually worth knowing about.

Installation

You can install the package via composer:

composer require alibori/laravel-watson

You can publish the config file with:

php artisan vendor:publish --tag="watson-config"

Usage

1. Configure the AI provider

Watson uses the Laravel AI SDK. Set up a provider and its API key as described in its docs (e.g. OPENAI_API_KEY or ANTHROPIC_API_KEY in your .env).

2. Configure Watson

WATSON_ENABLED=true
WATSON_CHANNEL=mail
WATSON_ROUTE=dev-team@example.com
  • WATSON_ENABLED: master switch. Set to false locally or in tests.
  • WATSON_CHANNEL: notification channel used to deliver the analysis. For now only works with mail.
  • WATSON_ROUTE: destination for that channel (an email address for mail). Watson does nothing if it's empty.

3. Hook it into your exception handler

In bootstrap/app.php:

use Alibori\LaravelWatson\LaravelWatson;
use Illuminate\Foundation\Configuration\Exceptions;

->withExceptions(function (Exceptions $exceptions) {
    $exceptions->report(function (Throwable $e) {
        LaravelWatson::handle($e);
    });
})

4. Run a queue worker

The analysis runs in a queued job, so your requests are never slowed down by the AI call:

php artisan queue:work

Each notification includes a summary, the likely cause, a suggested fix and a severity (low, medium, high, critical).

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.