Laravel 11 – 13
PHP 8.2+
A long-lived project that still receives updates
Monitor exception and report to the notification channels(Log、Mail、AnPush、Bark、Chanify、DingTalk、Discord、Gitter、GoogleChat、IGot、Lark、Mattermost、MicrosoftTeams、NowPush、Ntfy、Push、Pushback、PushBullet、PushDeer、PushMe、Pushover、PushPlus、QQ、RocketChat、ServerChan、ShowdocPush、SimplePush、Slack、Telegram、WeWork、WPush、XiZhi、YiFengChuanHua、ZohoCliq、ZohoCliqWebHook、Zulip).
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

adamwojs/php-cs-fixer-phpdoc-force-fqcn
^2.0
bamarni/composer-bin-plugin
^1.9
brainmaestro/composer-git-hooks
^3.0
canvural/larastan-strict-rules
^3.0
ergebnis/license
^2.7
ergebnis/php-cs-fixer-config
^6.60
ergebnis/phpstan-rules
^2.13
ergebnis/rector-rules
^1.16
guanguans/monorepo-builder-worker
^3.1
guanguans/php-cs-fixer-custom-fixers
^1.2
guanguans/phpstan-rules
^1.1
guanguans/rector-rules
^1.7
jbelien/phpstan-sarif-formatter
^1.2
laravel/facade-documenter
dev-main
mockery/mockery
^1.6
mrpunyapal/peststan
^0.2
mrpunyapal/rector-pest
^0.2
nette/utils
^4.1
nicksdot/phpstan-phpstorm-error-identifiers
^0.3
^9.17 || ^10.0 || ^11.0
^3.8 || ^4.0
pestphp/pest-plugin-arch
^3.1 || ^4.0
php-mock/php-mock-phpunit
^2.15
phpstan/extension-installer
^1.4
phpstan/phpstan-deprecation-rules
^2.0
phpstan/phpstan-mockery
^2.0
phpstan/phpstan-strict-rules
^2.0
phpstan/phpstan-webmozart-assert
^2.0
phpunit/phpunit
^11.5 || ^12.0 || ^13.0
povils/phpmnd
^3.6
rector/argtyper
^0.6
rector/jack
^0.5
rector/swiss-knife
^2.3
rector/type-perfect
^2.1
roave/backward-compatibility-check
^8.14
roave/no-floaters
^1.13
shipmonk/composer-dependency-analyser
^1.8
shipmonk/name-collision-detector
^2.1
shipmonk/phpstan-baseline-per-identifier
^2.3
shipmonk/phpstan-rules
^4.3
sidz/phpstan-rules
^0.5
spatie/invade
^2.1
spaze/phpstan-disallowed-calls
^4.9
staabm/annotate-pull-request-from-checkstyle
^1.8
staabm/phpstan-todo-by
^0.3
staabm/side-effects-detector
^1.0
symfony/thanks
^1.4
symplify/coding-standard
^13.0
symplify/easy-coding-standard
^13.0
symplify/phpstan-rules
^14.9
tomasvotruba/class-leak
^2.1
tomasvotruba/cognitive-complexity
^1.1
tomasvotruba/ctor
^2.2
tomasvotruba/type-coverage
^2.1
tomasvotruba/unused-public
^2.2
yamadashy/phpstan-friendly-formatter
^1.4

Runtime

^11.51 || ^12.0 || ^13.0
 Project Readme

laravel-exception-notify

usage

Monitor exception and report to the notification channels(Log、Mail、AnPush、Bark、Chanify、DingTalk、Discord、Gitter、GoogleChat、IGot、Lark、Mattermost、MicrosoftTeams、NowPush、Ntfy、Push、Pushback、PushBullet、PushDeer、PushMe、Pushover、PushPlus、QQ、RocketChat、ServerChan、ShowdocPush、SimplePush、Slack、Telegram、WeWork、WPush、XiZhi、YiFengChuanHua、ZohoCliq、ZohoCliqWebHook、Zulip).

tests php-cs-fixer codecov Latest Stable Version GitHub release (with filter) Total Downloads License

Why?

When an exception occurs, we want to be notified immediately, so that we can fix the problem as soon as possible. This package provides a simple and flexible way to monitor exceptions and report them to the notification channels.

Related repositories

Requirement

  • PHP >= 8.2

Installation

composer require guanguans/laravel-exception-notify --ansi -v

Configuration

Publish files(optional)

php artisan vendor:publish --provider="Guanguans\\LaravelExceptionNotify\\ExceptionNotifyServiceProvider" --ansi -v

Apply for channel authentication information

Configure channels in the config/exception-notify.php and .env file

#EXCEPTION_NOTIFY_CHANNEL=stack
EXCEPTION_NOTIFY_STACK_CHANNELS=log,mail,slack
EXCEPTION_NOTIFY_MAIL_TO_ADDRESS=developer1@example.mail,developer2@example.mail
EXCEPTION_NOTIFY_SLACK_WEBHOOK=https://hooks.slack.com/services/TPU9A9/B038KNUC0GY/6pKH3vfa3mjlUPcgLSjzR

Usage

Test whether exception can be monitored and reported to notification channel

php artisan exception-notify:test --channel=log --job-connection=sync
php artisan exception-notify:test
php artisan exception-notify:test -v

📸 Notification examples

🧐 details
discord slack telegram
discord slack telegram
lark mail weWork
lark mail weWork

Skip report

bootstrap/app.php
<?php

use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;

return Application::configure(basePath: \dirname(__DIR__))
    ->withExceptions(static function (Exceptions $exceptions): void {
        $exceptions
            // ->dontReportWhen(static fn (Throwable $throwable) => collect([
            //     \Symfony\Component\HttpKernel\Exception\HttpException::class,
            //     \Illuminate\Http\Exceptions\HttpResponseException::class,
            // ])->contains(static fn (string $exception): bool => $throwable instanceof $exception))
            ->dontReport([
                \Symfony\Component\HttpKernel\Exception\HttpException::class,
                \Illuminate\Http\Exceptions\HttpResponseException::class,
            ]);
    })->create();
Or app/Providers/AppServiceProvider.php
<?php

use Guanguans\LaravelExceptionNotify\Facades\ExceptionNotify;

public function boot(): void
{
    ExceptionNotify::skipWhen(static fn (\Throwable $throwable) => collect([
        \Symfony\Component\HttpKernel\Exception\HttpException::class,
        \Illuminate\Http\Exceptions\HttpResponseException::class,
    ])->contains(static fn (string $exception): bool => $throwable instanceof $exception));
}

Extend channel

app/Providers/AppServiceProvider.php
<?php

use Guanguans\LaravelExceptionNotify\Contracts\ChannelContract;
use Guanguans\LaravelExceptionNotify\Facades\ExceptionNotify;
use Illuminate\Container\Container;

public function boot(): void
{
    ExceptionNotify::extend('YourChannelName', function (Container $container): ChannelContract {
        return 'Instance of the `Guanguans\LaravelExceptionNotify\Contracts\ChannelContract`.';
    });
}

Composer scripts

composer checks:required
composer php-cs-fixer:fix
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

Thanks

License

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