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).
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.
- PHP >= 8.2
composer require guanguans/laravel-exception-notify --ansi -vphp artisan vendor:publish --provider="Guanguans\\LaravelExceptionNotify\\ExceptionNotifyServiceProvider" --ansi -v- Notify(30+)
- Log
- Stack
#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/6pKH3vfa3mjlUPcgLSjzRphp artisan exception-notify:test --channel=log --job-connection=sync
php artisan exception-notify:test
php artisan exception-notify:test -vbootstrap/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));
}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 checks:required
composer php-cs-fixer:fix
composer testPlease see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.






