soukar/qalert 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

soukar/qalert

最新稳定版本:v1.1.2

Composer 安装命令:

composer require soukar/qalert

包简介

description

README 文档

README

A simple, expressive tool to monitor your Laravel background jobs and get notified on failures instantly via Telegram and other channels.

🚀 Quick Start

1. Install via Composer

Run the following command in your terminal:

composer require soukar/qalert

2. Publish Configuration

Publish the config file to your project's config directory to customize channels and tokens:

php artisan vendor:publish --tag=qalert

3. Configure your Environment (.env)

Add your credentials to your .env file to activate the alerts:

# Master switch to enable/disable alerts
QALERT_ENABLED=true

# Telegram Bot Credentials
TELEGRAM_BOT_TOKEN=your_bot_token_here
TELEGRAM_CHAT_ID=your_chat_id_here

# Project name to show in the alert message
APP_NAME="My Awesome Service"

📝 Custom Logging Channel

You can now use QAlert as a standard Laravel logging channel. This allows you to send manual logs or specific application errors directly to your configured channels (like Telegram).

Setup Logging

Add the qalert driver to your config/logging.php file:

'channels' => [
    // ... other channels
    
    'qalert' => [
        'driver' => 'qalert',
    ],
],

⚙️ Configuration File (config/qalert.php)

After publishing, you can fine-tune the behavior of the package:

Key Description Default

enabled Globally enable or disable true notifications.

project The project name that appears APP_NAME in the alert title.

channels.telegram Stores the bot token and chat .env ID.

default_channel The fallback channel if none telegram is specified.

🛠 How it Works

QAlert automatically listens for the JobFailed event in Laravel.

When a job fails:

  • It gathers the job details and the exception message.
  • It processes the event through the configured channels in the ChannelManager.
  • It sends a formatted notification to each active channel (e.g., Telegram).

💓 Queue Heartbeat (Stay Alive)

QAlert isn't just for failed jobs; it also ensures your Queue Workers are actually running. It uses a Heartbeat system that leverages Laravel's default Scheduling system.

How to activate it:

  1. Ensure your Laravel Scheduler is running (* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1).
  2. QAlert will automatically schedule a "Ping" job every hour (or your custom interval).
  3. If the Heartbeat job isn't processed within the expected timeframe, you'll receive a "Queue Stalled" alert on Telegram.

This ensures that even if the supervisor stops or the connection to Redis/Database is lost, you'll still be the first to know.

🤝 Contributing

Contributions are welcome!
If you'd like to add a new channel (Slack, Discord, SMS), feel free to open a Pull Request.

❤️ Author

Developed with ❤️ by Mohammad Soukar

统计信息

  • 总下载量: 28
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固