- How do I install spatie/laravel-failed-job-monitor in a Laravel project?
- Run `composer require spatie/laravel-failed-job-monitor` to install the package. If using Slack notifications, also install Guzzle with `composer require guzzlehttp/guzzle`. Publish the config file using `php artisan vendor:publish --tag=failed-job-monitor-config` and update your `.env` with the required settings.
- Which Laravel versions does this package support?
- The package supports Laravel 8 through 13. For older versions (5.8–7.x), use version 3.x of the package. Always check the [GitHub repo](https://github.com/spatie/laravel-failed-job-monitor) for the latest compatibility details.
- Can I customize which jobs trigger notifications?
- Yes, the package allows filtering failed jobs via the `failed_job_monitor` config file. You can exclude specific jobs or use closures to define custom logic, though closures must be static methods or classes due to serialization limitations.
- How do I configure Slack notifications?
- Add your Slack webhook URL to `.env` under `FAILED_JOB_SLACK_WEBHOOK_URL`. Ensure the webhook is secure—avoid hardcoding it in version control or logs. Use a secrets manager like Laravel Forge or AWS Secrets Manager for production environments.
- Will this package slow down my queue workers?
- Notifications are sent synchronously during job failure, which could add latency. For high-volume systems, disable notifications in production (`FAILED_JOB_MONITOR_ENABLED=false`) or filter jobs to reduce noise. Test under load in staging to assess performance impact.
- Can I extend the package to use custom notification channels?
- Yes, the package leverages Laravel’s notification system, so you can create custom notification classes (e.g., for PagerDuty, Datadog) and bind them to the `FailedJob` event. Refer to the [Laravel Notifications documentation](https://laravel.com/docs/notifications) for implementation details.
- Does this package work with all Laravel queue drivers?
- Yes, the package is agnostic to the queue driver (database, Redis, SQS, etc.) as long as Laravel’s queue system is configured. It hooks into Laravel’s `failed` event for queue jobs, which is driver-independent.
- How do I test if notifications are working correctly?
- Manually trigger a job failure in your test environment (e.g., by throwing an exception in a job) and verify the notification arrives. Use Laravel’s `fake()` method to mock notifications in unit tests, or check logs if using Slack.
- What happens if I don’t want to store failed jobs in the database?
- This package does not persist failed jobs—it only sends notifications. If you need a record of failures, pair it with Laravel’s `queue:failed` table or a custom logging solution. The package focuses solely on alerting, not storage.
- Are there alternatives to this package for Laravel job monitoring?
- Alternatives include custom solutions using Laravel’s `failed` event listener, packages like `spatie/laravel-activitylog` for logging, or third-party tools like Sentry or Bugsnag. However, this package is specifically optimized for simple, configurable notifications without extra dependencies.