Search by

alibori / laravel-watson

alibori

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.

Package info

github.com/alibori/laravel-watson

pkg:composer/alibori/laravel-watson

Fund package maintenance!

Axel Libori Roch

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-11-18 14:09 UTC

This package is auto-updated.

Last update: 2026-11-18 14:22:53 UTC


README

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.