bluecloud / sms-queue
短信队列
v1.0.3
2021-03-13 02:00 UTC
README
将您的 Laravel 应用程序中的队列消息发送到您的 SMS API。
免责声明 此包不处理向接收者发送消息的实际操作。您需要 SMS 解决方案来处理这一点。但是,这将在代码的任何地方简化短信的调度和队列任务
快速指南
通过 composer 安装包
composer require bluecloud/sms-queue
发布包服务提供者
php artisan vendor:publish --provider=Bluecloud\SmsQueue\SmsQueueServiceProvider
运行迁移以创建 sms 队列表
php artisan migrate
队列消息
use Bluecloud\SmsQueue\Models\Message; Message::queue('0888800800', 'Test message'); Message::queue('0888800800', 'Test message', '2021-03-13 09:30:00');
发送消息
php artisan sms:send
要限制每批发送的消息数量,请设置环境变量 SMS_QUEUE_DELIVERIES_PER_BATCH
。
要设置一次性限制,请使用 php artisan sms:send --limit=10
您可以使用 Laravel Scheduler 安排消息的发送间隔
// app/Console/Kernel.php use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; class Kernel extends ConsoleKernel { protected function schedule(Schedule $schedule) { $schedule->command('sms:send')->everyMinute()->runInBackground(); } }
配置
要设置您的配置,请在您的环境文件中创建以下条目,并根据需要替换默认值
SMS_QUEUE_DELIVERIES_PER_BATCH=100 SMS_QUEUE_MESSENGER_URL=https://