Looking to hire Laravel developers? Try LaraJobs

laravel-exception-monitor maintained by zanysoft

Description
A lightweight Laravel package that notifies you of exceptions in your application via email, Slack, or Microsoft Teams.
Author
Last update
2026/07/30 16:35 (dev-main)
License
Links
Downloads
289

Comments
comments powered by Disqus

Software License Total Downloads Version Maintained Framwork

Laravel Exception Monitor

This package notifies you when exceptions are thrown on some of your production application.

Installation

composer require zanysoft/laravel-exception-monitor

If you’re on Laravel 5.4 or earlier, you’ll need to add the following to your config/app.php (for Laravel 5.5 and up these will be auto-discovered by Laravel):

'providers' => [
    //...
    ZanySoft\LaravelExceptionMonitor\ExceptionMonitorServiceProvider::class,
],

'aliases' => [
    //...
    'ExceptionMonitor' => ZanySoft\LaravelExceptionMonitor\Facades\ExceptionMonitor::class,
];

Publish the package config and view files to your application. Run these commands inside your terminal.

php artisan vendor:publish --provider="ZanySoft\LaravelExceptionMonitor\ExceptionMonitorServiceProvider"

You need set Incoming Webhooks for sending messages to Slack and MS Teams.

Configuration

Config File is pretty self-explanatory.

<?php

return [
    /*
     |--------------------------------------------------------------------------
     | Enabled sender drivers
     |--------------------------------------------------------------------------
     |
     | Send a notification about exception in your application to supported channels.
     |
     | Supported: "mail", "slack" and "teams". You can use multiple drivers.
     |
     */
    'drivers'      => [ 'mail', 'slack','teams' ],

    /*
     |--------------------------------------------------------------------------
     | Enabled application environments
     |--------------------------------------------------------------------------
     |
     | Set environments that should generate notifications.
     |
     */
    'environments' => [ 'production'],

    /*
     |--------------------------------------------------------------------------
     | Disable Error Notifications
     |--------------------------------------------------------------------------
     |
     | Set status code for disable notifications. like [401,404,500] 
     |
     */
    'skip_error' => [401, 404, 405, 500],

    /*
     |--------------------------------------------------------------------------
     | Mail Configuration
     |--------------------------------------------------------------------------
     |
     | It uses your app default Mail driver. You shouldn't probably touch the view
     | property unless you know what you're doing.
     |
     */
    'mail'         => [
        'from' => 'sender@example.com',
        'to'   => 'recipient@example.com',
        'view' => 'mails/exception-monitor'
    ],

    /*
     * set endpoint url from Incoming WebHooks https://my.slack.com/services/new/incoming-webhook
     */
    'slack' => [
        'endpoint' => 'https://hooks.slack.com/services/....',
        'channel' => '#bugtracker',
        'username' => 'Exception Monitor',
        'icon' => ':robot_face:',
    ],
    
    /*
     * Set endpoint url from Incoming WebHooks
     */
    'teams' => [
        'endpoint' => env('TEAMS_WEBHOOK_URL'),
        'title' => env('TEAMS_MESSAGE_TITLE', env('app_name')),
        'style' => 'card', // Display error type in teams notification. Allowed value: true (default) and false
        'show_user' => true, // Display authenticated user (if available). Allowed value: false (default) and true
        'exception_limit' => 5, // Display number of exception lines (trace). Set null for hide and -1 for all Default: 10,
        'avatar' => null,
        'color' => 'FF8000', // set message style color
    ],
];

Usage

To start catching exceptions you have 2 options out there.

First option: Extend from Exception Handler provided by package (app/Exceptions/Handler.php):

use ZanySoft\LaravelExceptionMonitor\MonitorExceptionHandler;
...
class Handler extends MonitorExceptionHandler

Second option: Make your report method in app/Exceptions/Handler.php to look like this:

public function report(Exception $e)
{
    foreach ($this->dontReport as $type) {
        if ($e instanceof $type) {
            return parent::report($e);
        }
    }

    if (app()->bound('exception-monitor')) {
        app('exception-monitor')->notifyException($e);
    }
  
    // OR
  
    ExceptionMonitor::notifyException($e);

    parent::report($e);
}

Examples

Slack

Teams

Issues

If you discover any issues, please email me at zanysoft.us@gmail.com instead of using the issue tracker.

License

This library is licensed under the MIT license. Please see License file for more information.