PHPackages                             kam2yar/failure-notifier - 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. [Mail &amp; Notifications](/categories/mail)
4. /
5. kam2yar/failure-notifier

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

kam2yar/failure-notifier
========================

Service that helps you to send notifications for a series of failed exceptions.

1.8(3y ago)77MITPHPPHP &gt;=7.4

Since May 28Pushed 3y ago1 watchersCompare

[ Source](https://github.com/kam2yar/Laravel-Failure-Notifier)[ Packagist](https://packagist.org/packages/kam2yar/failure-notifier)[ Docs](https://kamyar.dev)[ RSS](/packages/kam2yar-failure-notifier/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (3)Versions (11)Used By (0)

Laravel Failure Notifier
========================

[](#laravel-failure-notifier)

This package helps you to track your exceptions and do what you want to do with them such as sending an **SMS** or an **Email**.

You can specify the amount of time to count the exceptions.

If you had more exceptions than you expect, the service will run your **function**, then you can send a notification or whatever you want.

This package uses your default cache driver to count the exceptions. You are free to choose the driver, but we suggest you to use **Redis** for that.

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

[](#installation)

You need to add this package to your project by:

```
composer require kam2yar/failure-notifier

```

Optional: The service provider will automatically get registered. Or you may manually add the service provider in your `config/app.php` file:

```
'providers' => [
    // ...
    FailureNotifier\FailureNotifierServiceProvider::class
]

```

After you need to run the below command to copy the configuration file to your project directory.

```
php artisan vendor:publish --provider="FailureNotifier\FailureNotifierServiceProvider"

```

After this, you are free to remove it from your provider's array.

### Add the service to the handler

[](#add-the-service-to-the-handler)

You must add the service to the `Exceptions\Handler.php` file to capture the exceptions.

Add the report method to the "Handler" class as below:

```
public function report(Throwable $exception)
{
    if ($this->shouldReport($exception) and app()->bound(FailureNotifier::class) and app()->bound(FailureHandlerInterface::class)) {
        app(FailureNotifier::class)->capture($exception);
    }

    parent::report($exception);
}

```

### Write your custom failure handler

[](#write-your-custom-failure-handler)

You must write a new class in your project and pass it to the capture method that implements the `FailureHandlerInterface`interface:

```
use FailureNotifier\FailureHandlerInterface;.
use Illuminate\Support\Facades\Log;
use Throwable;

class FailureHandler implements FailureHandlerInterface
{
    public function handleException(Throwable $exception, int $failureCount)
    {
        $exceptionClass = get_class($exception);

        switch ($exceptionClass) {
            default:
                Log::warning('Handle default exception', ['class' => $exceptionClass]);
                break;
        }
    }
}

```

### Bind your custom handler to your application

[](#bind-your-custom-handler-to-your-application)

Now you need to add your custom failure handler to your `App\Providers\AppServiceProvider` file.

Add the bellow code to the boot function:

```
public function boot()
{
    $this->app->singleton(FailureHandlerInterface::class, function ($app) {
        // Your custom failure handler

        return new FailureHandler();
    });
}

```

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

[](#configuration)

You can change the service configuration by editing the `config\failure-notifier.php` file.

You can have a setting for each type of exception. or you can leave it to use the default configuration.

To add a new exception you need to add a new record to the "exceptions" array like the below example:

```
   \App\Exceptions\ExampleException::class => [
       'count' => 5,
       'interval' => 600,
       'lock_until' => 600,
       'active' => true
   ],

```

### Parameters

[](#parameters)

**Count:** Minimum count of exceptions needs to raise to run your function.

**Interval:** Seconds to store the count of exceptions in the cache.

**Lock Until:** Seconds to prevent sending duplicate notify

**Active:** Enable or disable service for this type of exception

### Deactivate the service

[](#deactivate-the-service)

If you need to disable the service, you can set a new key in your `.env` file.

```
FAILURE_NOTIFIER_ACTIVE=false

```

### Contribution

[](#contribution)

Please tell me about the feature or issues before start developing it. Thank you.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

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 ~3 days

Total

9

Last Release

1414d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c752c87dbcc724460f2066e00f8462c8cfba505adc41f7c9586507c6048a1021?d=identicon)[kam2yar](/maintainers/kam2yar)

---

Top Contributors

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

---

Tags

laravellumen

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kam2yar-failure-notifier/health.svg)

```
[![Health](https://phpackages.com/badges/kam2yar-failure-notifier/health.svg)](https://phpackages.com/packages/kam2yar-failure-notifier)
```

###  Alternatives

[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[spatie/laravel-mailcoach-sdk

An SDK to easily work with the Mailcoach API in Laravel apps

41290.2k1](/packages/spatie-laravel-mailcoach-sdk)[princealikhan/laravel-mautic-api

Free and Open Source Marketing Automation API

415.9k](/packages/princealikhan-laravel-mautic-api)[matthewbdaly/laravel-sms

A Laravel and Lumen integration for matthewbdaly/sms-client to enable sending SMS messages

3529.8k](/packages/matthewbdaly-laravel-sms)

PHPackages © 2026

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