infoesportes/messaging-laravel
Composer 安装命令:
composer require infoesportes/messaging-laravel
包简介
Laravel adapter for InfoEsportes messaging microservice with RabbitMQ, Horizon integration for Email, SMS, and WhatsApp
README 文档
README
Laravel adapter for InfoEsportes messaging microservice with RabbitMQ. Provides Horizon integration for Email, SMS, and WhatsApp messaging.
Features
- 🚀 RabbitMQ Integration - Topic exchange with routing keys
- 📧 Email Support - Transactional and marketing emails
- 📱 SMS Support - OTP and alerts
- 💬 WhatsApp Support - Notifications and support messages
- 🔄 Laravel Horizon - Queue monitoring and management
- ⚡ Background Jobs - Async processing with Laravel queues
- 🎯 Routing Keys - Flexible message routing
- 🛡️ Reliability - Quorum queues for high availability
Architecture
CodeIgniter/Laravel → Plain JSON → RabbitMQ
↓
Consumer (ACK immediately)
↓
Dispatch Laravel Job
↓
Redis/Database Queue (Horizon)
↓
ProcessEmailJob/ProcessSMSJob/ProcessWhatsAppJob
Installation
composer require infoesportes/messaging-laravel
Publish Configuration
php artisan vendor:publish --tag=messaging-config
Environment Variables
Add to your .env file:
RABBITMQ_HOST=localhost RABBITMQ_PORT=5672 RABBITMQ_USER=guest RABBITMQ_PASSWORD=guest RABBITMQ_VHOST=/ RABBITMQ_EXCHANGE=messages.topic RABBITMQ_PREFETCH_COUNT=10 RABBITMQ_CONSUMER_TAG=laravel_consumer MESSAGING_QUEUE_CONNECTION=redis MESSAGING_QUEUE_NAME=messaging
Usage
Publishing Messages
Using Facade
use Infoesportes\Messaging\Laravel\Facades\Messaging; // Email - Transactional Messaging::publishEmail('transactional', [ 'to' => 'user@example.com', 'subject' => 'Your Invoice', 'body' => 'Invoice details...', ]); // Email - Marketing Messaging::publishEmail('marketing', [ 'to' => 'user@example.com', 'subject' => 'Newsletter', 'template' => 'newsletter', ]); // SMS - OTP Messaging::publishSms('otp', [ 'to' => '+5511999999999', 'code' => '123456', ]); // SMS - Alert Messaging::publishSms('alert', [ 'to' => '+5511999999999', 'message' => 'Urgent alert!', ]); // WhatsApp - Notification Messaging::publishWhatsApp('notification', [ 'to' => '+5511999999999', 'message' => 'You have a new message', ]); // WhatsApp - Support Messaging::publishWhatsApp('support', [ 'to' => '+5511999999999', 'message' => 'Support ticket created', ]);
Using Service Container
$messaging = app('messaging'); $messaging->publish('email.transactional', [ 'to' => 'user@example.com', 'subject' => 'Custom Email', ]);
Consuming Messages
Start the consumer for each queue type:
# Consume email messages php artisan messaging:consume email # Consume SMS messages php artisan messaging:consume sms # Consume WhatsApp messages php artisan messaging:consume whatsapp # With timeout (in seconds) php artisan messaging:consume email --timeout=3600
Supervisor Configuration
Create /etc/supervisor/conf.d/messaging-consumer.conf:
[program:messaging-email-consumer] process_name=%(program_name)s_%(process_num)02d command=php /path/to/artisan messaging:consume email autostart=true autorestart=true user=www-data numprocs=2 redirect_stderr=true stdout_logfile=/var/log/messaging-email-consumer.log [program:messaging-sms-consumer] process_name=%(program_name)s_%(process_num)02d command=php /path/to/artisan messaging:consume sms autostart=true autorestart=true user=www-data numprocs=1 redirect_stderr=true stdout_logfile=/var/log/messaging-sms-consumer.log [program:messaging-whatsapp-consumer] process_name=%(program_name)s_%(process_num)02d command=php /path/to/artisan messaging:consume whatsapp autostart=true autorestart=true user=www-data numprocs=1 redirect_stderr=true stdout_logfile=/var/log/messaging-whatsapp-consumer.log
Then reload supervisor:
sudo supervisorctl reread sudo supervisorctl update sudo supervisorctl start messaging-email-consumer:* sudo supervisorctl start messaging-sms-consumer:* sudo supervisorctl start messaging-whatsapp-consumer:*
Routing Keys
The package uses the following routing key structure:
email.transactional- Invoices, receipts, confirmationsemail.marketing- Newsletters, promotions
SMS
sms.otp- One-time passwords, verification codessms.alert- Urgent alerts, notifications
whatsapp.notification- General notificationswhatsapp.support- Support messages, tickets
Job Processing
The consumer dispatches jobs to Laravel's queue system. Customize the job classes:
ProcessEmailJob
namespace Infoesportes\Messaging\Laravel\Jobs; use Illuminate\Support\Facades\Mail; class ProcessEmailJob implements ShouldQueue { public function handle(): void { // Implement your email sending logic Mail::to($this->data['to']) ->send(new YourMailable($this->data)); } }
ProcessSMSJob
public function handle(): void { // Implement your SMS provider logic $smsProvider = app(SMSProviderInterface::class); $smsProvider->send($this->data['to'], $this->data['message']); }
ProcessWhatsAppJob
public function handle(): void { // Implement your WhatsApp provider logic $whatsappProvider = app(WhatsAppProviderInterface::class); $whatsappProvider->send($this->data['to'], $this->data['message']); }
Testing
composer test
Code Style
composer format
Configuration
See config/messaging.php for all available options.
Key configuration sections:
- RabbitMQ Connection - Host, port, credentials
- Exchange Configuration - Topic exchange settings
- Queue Configuration - Queue names, routing keys, durability
- Consumer Configuration - Prefetch count, consumer tag
- Job Mapping - Map queue types to job classes
Horizon Integration
This package works seamlessly with Laravel Horizon. Jobs dispatched from the RabbitMQ consumer appear in Horizon for monitoring:
- Install Horizon:
composer require laravel/horizon - Publish config:
php artisan horizon:install - Start Horizon:
php artisan horizon - View dashboard:
http://your-app.test/horizon
Requirements
- PHP 8.1 or higher
- Laravel 10.x or 11.x
- RabbitMQ 3.8 or higher
- Redis (for queue driver)
Credits
License
The MIT License (MIT). Please see License File for more information.
infoesportes/messaging-laravel 适用场景与选型建议
infoesportes/messaging-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 64 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 01 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「email」 「sms」 「rabbitmq」 「messaging」 「laravel」 「whatsapp」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 infoesportes/messaging-laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 infoesportes/messaging-laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 infoesportes/messaging-laravel 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Work with RabbitMQ in Laravel.
Microservice RPC through message queues.
PHP AMQP Binding Library
SDK for payment gateway PlatbaMobilom.sk for PHP7.0
Extensible library for building notifications and sending them via different delivery channels.
Email+ extends Kirby's email capabilities by adding support for multiple email services using the same Kirby email API.
统计信息
- 总下载量: 64
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 31
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-23