2017 © Pedro Peláez
 

library laravel-failed-job-monitor

Get notified when a queued job fails

image

spatie/laravel-failed-job-monitor

Get notified when a queued job fails

  • Tuesday, February 13, 2018
  • by Spatie
  • Repository
  • 15 Watchers
  • 351 Stars
  • 108,464 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 27 Forks
  • 0 Open issues
  • 15 Versions
  • 11 % Grown

The README.md

Get notified when a queued job fails

Latest Version on Packagist Test Status Software License Total Downloads, (*1)

This package sends notifications if a queued job fails. Out of the box it can send a notification via mail and/or Slack. It leverages Laravel's native notification system., (*2)

Support us

, (*3)

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products., (*4)

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall., (*5)

Installation

For Laravel versions 5.8 and 6.x, use v3.x of this package., (*6)

You can install the package via composer:, (*7)

``` bash composer require spatie/laravel-failed-job-monitor, (*8)

If you intend to use Slack notifications you should also install the guzzle client:

``` bash
composer require guzzlehttp/guzzle

The service provider will automatically be registered., (*9)

Next, you must publish the config file:, (*10)

php artisan vendor:publish --tag=failed-job-monitor-config

This is the contents of the default configuration file. Here you can specify the notifiable to which the notifications should be sent. The default notifiable will use the variables specified in this config file., (*11)

return [

    /**
     * The notification that will be sent when a job fails.
     */
    'notification' => \Spatie\FailedJobMonitor\Notification::class,

    /**
     * The notifiable to which the notification will be sent. The default
     * notifiable will use the mail and slack configuration specified
     * in this config file.
     */
    'notifiable' => \Spatie\FailedJobMonitor\Notifiable::class,

    /*
     * By default notifications are sent for all failures. You can pass a callable to filter
     * out certain notifications. The given callable will receive the notification. If the callable
     * return false, the notification will not be sent.
     */
    'notificationFilter' => null,

    /**
     * The channels to which the notification will be sent.
     */
    'channels' => ['mail', 'slack'],

    'mail' => [
        'to' => ['email@example.com'],
    ],

    'slack' => [
        'webhook_url' => env('FAILED_JOB_SLACK_WEBHOOK_URL'),
    ],
];

Configuration

Customizing the notification

The default notification class provided by this package has support for mail and Slack., (*12)

If you want to customize the notification you can specify your own notification class in the config file., (*13)

// config/failed-job-monitor.php
return [
    ...
    'notification' => \App\Notifications\CustomNotificationForFailedJobMonitor::class,
    ...

Customizing the notifiable

The default notifiable class provided by this package use the channels, mail and slack keys from the config file to determine how notifications must be sent, (*14)

If you want to customize the notifiable you can specify your own notifiable class in the config file., (*15)

// config/failed-job-monitor.php
return [
    'notifiable' => \App\CustomNotifiableForFailedJobMonitor::class,
    ...

Filtering the notifications

To filter the notifications, pass a closure to the notificationFilter., (*16)

// config/failed-job-monitor.php
return [
    ...
    'notificationFilter' => function (Spatie\FailedJobMonitor\Notification $notification): bool
    {
        return true;
    }
    ...

The above works only that Laravel doesn't support closure serialization. Thus you will get the following error when you run php artisan config:cache, (*17)

LogicException  : Your configuration files are not serializable.

It would thus be better to create a separate class and use a callable as the callback., (*18)

<?php

namespace App\Notifications;

use Spatie\FailedJobMonitor\Notification;

class FailedJobNotification
{
    public static function notificationFilter(Notification $notification): bool
    {
        return true;
    }
}

And reference it in the configuration file., (*19)

// config/failed-job-monitor.php
return [
    ...
    'notificationFilter' => [App\Notifications\FailedJobNotification::class, 'notificationFilter'],
    ...

Usage

If you configured the package correctly, you're done. You'll receive a notification when a queued job fails., (*20)

Changelog

Please see CHANGELOG for more information what has changed recently., (*21)

Testing

bash composer test, (*22)

Contributing

Please see CONTRIBUTING for details., (*23)

Security

If you've found a bug regarding security please mail security@spatie.be instead of using the issue tracker., (*24)

Credits

A big thank you to Egor Talantsev for his help creating v2 of the package., (*25)

License

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

The Versions

01/09 2017

3.0.0

3.0.0.0 https://github.com/spatie/laravel-failed-job-monitor

Get notified when a queued job fails

  Sources   Download

MIT

The Requires

 

The Development Requires

queue job slack monitor spatie notify laravel-failed-job-monitor

14/06 2017

v2.x-dev

2.9999999.9999999.9999999-dev https://github.com/spatie/laravel-failed-job-monitor

Get notified when a queued job fails

  Sources   Download

MIT

The Requires

 

The Development Requires

queue job slack monitor spatie notify laravel-failed-job-monitor

23/01 2017

2.2.0

2.2.0.0 https://github.com/spatie/laravel-failed-job-monitor

Get notified when a queued job fails

  Sources   Download

MIT

The Requires

 

The Development Requires

queue job slack monitor spatie notify laravel-failed-job-monitor

07/11 2016

2.1.1

2.1.1.0 https://github.com/spatie/laravel-failed-job-monitor

Get notified when a queued job fails

  Sources   Download

MIT

The Requires

 

The Development Requires

queue job slack monitor spatie notify laravel-failed-job-monitor

07/11 2016

dev-analysis-8PBYpY

dev-analysis-8PBYpY https://github.com/spatie/laravel-failed-job-monitor

Get notified when a queued job fails

  Sources   Download

MIT

The Requires

 

The Development Requires

queue job slack monitor spatie notify laravel-failed-job-monitor

07/11 2016

2.1.0

2.1.0.0 https://github.com/spatie/laravel-failed-job-monitor

Get notified when a queued job fails

  Sources   Download

MIT

The Requires

 

The Development Requires

queue job slack monitor spatie notify laravel-failed-job-monitor

18/10 2016

2.0.0

2.0.0.0 https://github.com/spatie/laravel-failed-job-monitor

Get notified when a queued job fails

  Sources   Download

MIT

The Requires

 

The Development Requires

queue job slack monitor spatie notify laravel-failed-job-monitor

11/09 2016

1.1.0

1.1.0.0 https://github.com/spatie/laravel-failed-job-monitor

Get notified when a queued job fails

  Sources   Download

MIT

The Requires

 

The Development Requires

queue job slack monitor spatie notify laravel-failed-job-monitor

27/08 2016

1.0.3

1.0.3.0 https://github.com/spatie/laravel-failed-job-monitor

Get notified when a queued job fails

  Sources   Download

MIT

The Requires

 

The Development Requires

queue job slack monitor spatie notify laravel-failed-job-monitor

02/03 2016

1.0.2

1.0.2.0 https://github.com/spatie/laravel-failed-job-monitor

Get notified when a queued job fails

  Sources   Download

MIT

The Requires

 

The Development Requires

queue job slack monitor spatie notify laravel-failed-job-monitor

26/02 2016

1.0.1

1.0.1.0 https://github.com/spatie/laravel-failed-job-monitor

Get notified when a queued job fails

  Sources   Download

MIT

The Requires

 

The Development Requires

queue job slack monitor spatie notify laravel-failed-job-monitor

25/02 2016

1.0.0

1.0.0.0 https://github.com/spatie/laravel-failed-job-monitor

Get notified when a queued job fails

  Sources   Download

MIT

The Requires

 

The Development Requires

queue job slack monitor spatie notify laravel-failed-job-monitor

24/02 2016

0.0.1

0.0.1.0 https://github.com/spatie/laravel-failed-jobs-monitor

Sends notifications if the queued job fails.

  Sources   Download

MIT

The Requires

 

The Development Requires

spatie laravel-failed-jobs-monitor