PHPackages                             lbose/laravel-error-analyzer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. lbose/laravel-error-analyzer

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

lbose/laravel-error-analyzer
============================

AI-driven error analysis, GitHub issue creation, and Slack notifications for Laravel applications

0.1.4(4mo ago)0378[2 issues](https://github.com/lbose-corp/laravel-error-analyzer/issues)MITPHPPHP ^8.3CI passing

Since Feb 1Pushed 4mo agoCompare

[ Source](https://github.com/lbose-corp/laravel-error-analyzer)[ Packagist](https://packagist.org/packages/lbose/laravel-error-analyzer)[ RSS](/packages/lbose-laravel-error-analyzer/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (3)Dependencies (12)Versions (7)Used By (0)

Laravel Error Analyzer
======================

[](#laravel-error-analyzer)

AI-driven error analysis, GitHub issue creation, and Slack notifications for Laravel applications.

Features
--------

[](#features)

- 🤖 **AI-Powered Analysis**: Analyze errors using Google Gemini AI
- 🐛 **Automatic Issue Creation**: Create GitHub issues for critical errors
- 📢 **Slack Notifications**: Send notifications to Slack channels
- 🔒 **PII Protection**: Automatically sanitize sensitive data from stack traces
- 🚦 **Quota Management**: Daily limits to prevent API abuse
- 🔄 **Deduplication**: Avoid analyzing the same error multiple times
- 🎯 **Flexible Configuration**: Easily enable/disable features via environment variables

Requirements
------------

[](#requirements)

- PHP 8.3 or higher
- Laravel 11.0 or higher

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require lbose/laravel-error-analyzer
```

Publish the configuration file:

```
php artisan vendor:publish --tag=error-analyzer-config
```

Run migrations (package migrations are auto-loaded when `ERROR_ANALYZER_STORAGE_DRIVER=database`):

```
php artisan migrate
```

Configuration
-------------

[](#configuration)

### Environment Variables

[](#environment-variables)

Add these variables to your `.env` file:

```
# AI Analyzer (optional)
ERROR_ANALYZER_DRIVER=gemini
ERROR_ANALYZER_GEMINI_API_KEY=your-gemini-api-key

# Issue Tracker (optional)
ERROR_ANALYZER_ISSUE_TRACKER=github
ERROR_ANALYZER_GITHUB_TOKEN=your-github-token
ERROR_ANALYZER_GITHUB_REPOSITORY=username/repository
ERROR_ANALYZER_GITHUB_AI_TITLE_ENABLED=false
ERROR_ANALYZER_GITHUB_AI_TITLE_MODEL=gemini-2.5-flash-lite

# Notifications (optional)
ERROR_ANALYZER_NOTIFICATION=slack
ERROR_ANALYZER_SLACK_WEBHOOK=https://hooks.slack.com/services/xxx

# Analysis Settings
ERROR_ANALYZER_DAILY_LIMIT=100
ERROR_ANALYZER_ENABLED_ENVIRONMENTS=production,staging

# Storage Settings (optional)
ERROR_ANALYZER_STORAGE_DRIVER=database  # 'database' (default) or 'null' (disable DB storage)
```

### Optional Dependencies

[](#optional-dependencies)

Install optional dependencies based on your needs:

```
# For Gemini AI analysis
composer require google-gemini-php/laravel
```

If `ERROR_ANALYZER_GITHUB_AI_TITLE_ENABLED=true`, issue titles are optionally generated with Gemini and automatically fall back to the existing rule-based title when generation fails. Title generation uses the same `ERROR_ANALYZER_DAILY_LIMIT` quota as AI error analysis.

Basic Usage
-----------

[](#basic-usage)

### Exception Handler Integration

[](#exception-handler-integration)

Add error analysis to your exception handler:

```
use Lbose\ErrorAnalyzer\Jobs\AnalyzeErrorJob;
use Lbose\ErrorAnalyzer\Services\ErrorAnalysisService;

class Handler extends ExceptionHandler
{
    public function report(Throwable $exception): void
    {
        parent::report($exception);

        if ($this->shouldAnalyze($exception)) {
            $service = app(ErrorAnalysisService::class);

            if ($service->tryIncrementIfAllowed()) {
                dispatch(new AnalyzeErrorJob($exception, [
                    'environment' => app()->environment(),
                    'timestamp' => now()->toIso8601String(),
                    'url' => request()->fullUrl(),
                    'user_id' => auth()->check() ? (string) auth()->id() : 'guest',
                ]));
            }
        }
    }

    private function shouldAnalyze(Throwable $exception): bool
    {
        $enabledEnvironments = config('error-analyzer.analysis.enabled_environments', []);
        if (!in_array(app()->environment(), $enabledEnvironments, true)) {
            return false;
        }

        $excluded = config('error-analyzer.analysis.excluded_exceptions', []);
        foreach ($excluded as $excludedException) {
            if ($exception instanceof $excludedException) {
                return false;
            }
        }

        return true;
    }
}
```

### Artisan Commands

[](#artisan-commands)

Test error analysis:

```
# Trigger a test error
php artisan errors:test-analysis --type=runtime

# List all error reports
php artisan errors:test-analysis --list

# Show specific error report
php artisan errors:test-analysis --show=1
```

Cleanup old errors:

```
php artisan errors:cleanup
```

Advanced Configuration
----------------------

[](#advanced-configuration)

### Custom Analyzers

[](#custom-analyzers)

You can implement your own AI analyzer:

```
use Lbose\ErrorAnalyzer\Services\Contracts\AiAnalyzerInterface;

class CustomAnalyzer implements AiAnalyzerInterface
{
    public function analyze(
        string $exceptionClass,
        string $message,
        string $file,
        int $line,
        string $sanitizedTrace,
        array $sanitizedContext
    ): array {
        // Your custom implementation
        return [
            'severity' => 'high',
            'category' => 'other',
            'root_cause' => 'Custom analysis',
            'impact' => 'Custom impact',
            'immediate_action' => 'Custom immediate action',
            'recommended_fix' => 'Custom recommended fix',
            'similar_issues' => [],
            'prevention' => 'Custom prevention',
        ];
    }
}
```

Register your custom analyzer in a service provider:

```
$this->app->singleton(AiAnalyzerInterface::class, CustomAnalyzer::class);
```

### Storage Configuration

[](#storage-configuration)

By default, error reports are stored in the database. You can disable database storage by setting:

```
ERROR_ANALYZER_STORAGE_DRIVER=null
```

When database storage is disabled:

- Error reports are not saved to the database
- Deduplication uses cache instead of database unique constraints
- AI analysis, notifications, and issue creation still work normally
- Commands like `errors:test-analysis --list` and `errors:cleanup` will not work (they require database storage)

### Configuration Options

[](#configuration-options)

See `config/error-analyzer.php` for all available options:

- AI analyzer settings (driver, model, temperature, etc.)
- Issue tracker settings (repository, labels, assignees)
- Notification settings (webhook, severity threshold)
- Analysis behavior (daily limit, excluded exceptions, deduplication)
- Storage settings (driver, table name, cleanup days)

Architecture
------------

[](#architecture)

The package uses a driver-based architecture with the following components:

- **AiAnalyzerInterface**: AI-based error analysis (Gemini, custom, or null)
- **IssueTrackerInterface**: Automatic issue creation (GitHub or null)
- **NotificationChannelInterface**: Error notifications (Slack or null)
- **ErrorAnalysisService**: Quota management and rate limiting
- **FingerprintCalculator**: Error deduplication logic
- **PiiSanitizer**: PII removal from stack traces and context

PII masking currently targets common patterns (email, UUID, long hex tokens, Bearer/JWT-like tokens, some API keys). Application-specific secrets may still require custom masking.

Testing
-------

[](#testing)

The package includes comprehensive tests:

```
cd packages/laravel-error-analyzer
composer install
vendor/bin/pint --test
vendor/bin/phpstan analyse -l 6 --memory-limit=1G
vendor/bin/phpunit
```

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE) for details.

Credits
-------

[](#credits)

Developed by [LBOSE Corp](https://lbose.co.jp)

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance78

Regular maintenance activity

Popularity15

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 72.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~6 days

Total

5

Last Release

121d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3cd5f8a84e678622dc5463bba89a0a77f1b6a8a3bc6d85bd08e6a316e978fa3c?d=identicon)[lbose-jp](/maintainers/lbose-jp)

---

Top Contributors

[![narith-minami](https://avatars.githubusercontent.com/u/17946435?v=4)](https://github.com/narith-minami "narith-minami (13 commits)")[![lbose-jp](https://avatars.githubusercontent.com/u/64473108?v=4)](https://github.com/lbose-jp "lbose-jp (5 commits)")

---

Tags

laravelmonitoringerrorslackgithubanalysisGemini

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/lbose-laravel-error-analyzer/health.svg)

```
[![Health](https://phpackages.com/badges/lbose-laravel-error-analyzer/health.svg)](https://phpackages.com/packages/lbose-laravel-error-analyzer)
```

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k51.0M7.6k](/packages/larastan-larastan)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k14.1M122](/packages/laravel-pulse)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9742.3M122](/packages/roots-acorn)[spatie/laravel-health

Monitor the health of a Laravel application

87411.3M153](/packages/spatie-laravel-health)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
