PHPackages                             abenevaut/laravel-sentry-handler - 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. abenevaut/laravel-sentry-handler

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

abenevaut/laravel-sentry-handler
================================

Laravel sentry exceptions handler

1.0.2(2y ago)1218GPL-3.0-onlyPHPPHP ^8.1

Since Sep 18Pushed 2y ago1 watchersCompare

[ Source](https://github.com/abenevaut/laravel-sentry-handler)[ Packagist](https://packagist.org/packages/abenevaut/laravel-sentry-handler)[ RSS](/packages/abenevaut-laravel-sentry-handler/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (7)Versions (5)Used By (0)

laravel-sentry-handler
======================

[](#laravel-sentry-handler)

Package that facilitates sentry integration with context scoped exceptions that are able to transport data when an exception happened.

Install
-------

[](#install)

```
composer require abenevaut/laravel-sentry-handler
php artisan sentry:publish --dsn=
```

Usage
-----

[](#usage)

### Update ExceptionHandler

[](#update-exceptionhandler)

Scoped Exception vendorized in this package are able to report themself to Sentry. Because we probably want to report all exceptions to Sentry, we are able to implement `$this->reportSentry($e);` to record them to Sentry.

#### Inherited Handler

[](#inherited-handler)

In `app/Exceptions/Handler.php`, replace `use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;` by `use abenevaut\SentryHandler\Handler as ExceptionHandler;`

If you already customized your exception handler, be sure to adjust your `report()` method:

```
public function report(\Throwable $e): void
{
    // Report standard exceptions to sentry
    $this->reportSentry($e);

    parent::report($e);
}
```

Note: that method is used in [demo](https://github.com/abenevaut/demo-laravel-sentry-handler)

#### Handler Trait

[](#handler-trait)

In `app/Exceptions/Handler.php`, add `use SentryHandlerTrait;` in `App\Exceptions\Handler` class.

Then adjust your `report()` method:

```
public function report(\Throwable $e): void
{
    // Report standard exceptions to sentry
    $this->reportSentry($e);

    parent::report($e);
}
```

#### Test Sentry with standard exceptions

[](#test-sentry-with-standard-exceptions)

```
php artisan sentry:test

```

### Scoped Exceptions

[](#scoped-exceptions)

Laravel ExceptionHandler allows an exception to report herself by implementing `report()` method. We use that place to compute exception context and then throw it to Sentry.

```
final class MyException extends \abenevaut\SentryHandler\Contracts\ExceptionAbstract
{
    /**
     * @var array|string[]
     */
    private array $scopes = [
        /*
         * Context always reported
         */
        DefaultScope::class,
    ];
}

$exception = new MyException();

// Depending context, add relative scope
$exception->addScope( DefaultScope::class );
// You can also pass an instantiated object, if you required to compute something
$exception->addScope( new DefaultScope( ... ) );

report($exception);
```

- Set exception severity

```
// incoming soon
```

- Send Sentry message

```
// incoming soon
```

### What a scope

[](#what-a-scope)

```
final class DefaultScope extends \abenevaut\SentryHandler\Contracts\ScopeAbstract
{
    public function handle(Scope $scope, Closure $next)
    {
        /*
         * Stack context in Sentry scope.
         * @seealso https://docs.sentry.io/platforms/php/guides/laravel/enriching-events/?original_referrer=https%3A%2F%2Fwww.google.com%2F
         */
        $scope
            ->setUser([
                // ...
            ])
            ->setTags([
                // ...
            ]);

        return $next($scope);
    }
}
```

Tests
-----

[](#tests)

```
vendor/bin/smelly-code-detector inspect src
vendor/bin/phpunit
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~191 days

Total

4

Last Release

755d ago

Major Versions

0.1.0 → 1.0.02023-05-07

### Community

Maintainers

![](https://www.gravatar.com/avatar/46619d39f5bfbf68b122f68de36a3f3fae3dbee6f899876b42cba1de6f7e71ae?d=identicon)[abenevaut](/maintainers/abenevaut)

---

Top Contributors

[![abenevaut](https://avatars.githubusercontent.com/u/1134021?v=4)](https://github.com/abenevaut "abenevaut (6 commits)")

---

Tags

crash-reportinglaravelsentrylaravelexceptionshandlersentry

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/abenevaut-laravel-sentry-handler/health.svg)

```
[![Health](https://phpackages.com/badges/abenevaut-laravel-sentry-handler/health.svg)](https://phpackages.com/packages/abenevaut-laravel-sentry-handler)
```

###  Alternatives

[bugsnag/bugsnag-laravel

Official Bugsnag notifier for Laravel applications.

90234.6M36](/packages/bugsnag-bugsnag-laravel)[jenssegers/raven

Sentry (Raven) error monitoring integration for Laravel projects

92197.2k1](/packages/jenssegers-raven)

PHPackages © 2026

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