- How do I set up email notifications for failed Laravel jobs?
- Publish the config with `php artisan vendor:publish --tag=failed-job-monitor-config`, then configure the `mail.to` address in `.env` or the config file. Ensure your Laravel mail driver is properly set up to send emails.
- Can I use Slack instead of email for job failure alerts?
- Yes. Install Guzzle (`composer require guzzlehttp/guzzle`), add your Slack webhook URL to `.env` as `FAILED_JOB_SLACK_WEBHOOK_URL`, and configure the Slack channel in the published config file.
- Does this package work with Laravel Horizon?
- Yes, it integrates with Horizon. The default notification includes a link to Horizon’s job dashboard if it’s installed. If you’re not using Horizon, customize the notification class to remove the link.
- What Laravel versions does spatie/laravel-failed-job-monitor support?
- The latest version (v4.x) supports Laravel 8+ through 13. For Laravel 6.x, use v3.x. Check the [release notes](https://github.com/spatie/laravel-failed-job-monitor/releases) for version-specific details.
- How do I filter out specific job failures (e.g., transient errors)?
- Use the `notificationFilter` in the config file. Pass a closure that returns `false` for jobs you want to ignore. Note: Closures aren’t serializable, so use a static method instead for `config:cache` compatibility.
- Will this package slow down my job processing in production?
- No, the package adds minimal overhead during job execution. However, sending notifications (e.g., Slack API calls) could introduce latency if jobs fail en masse. Consider rate-limiting notifications or queuing them.
- Can I extend this to use PagerDuty or other alerting services?
- Absolutely. Replace the default `Notification` class with your own, leveraging Laravel’s notification system. Override the `toMail` or `toSlack` methods to forward alerts to PagerDuty or other channels.
- How do I test this package in a staging environment?
- Force a job failure in staging by throwing an exception in a job class. Verify notifications arrive by checking your mail inbox or Slack channel. Use a test Slack webhook or mail service like Mailtrap for isolated testing.
- Does this work with all Laravel queue drivers (Redis, SQS, etc.)?
- Yes, it supports all Laravel queue drivers. However, database queues may require tuning if job failures are frequent, as they could lead to table locking. Monitor performance if using this driver heavily.
- What if I need dynamic recipients (e.g., based on job type)?
- Create a custom `Notifiable` class and bind it in the config. Use environment variables or a service container to dynamically resolve recipients. Override the `routeNotificationFor` method to implement your logic.