befuturein/scheduled-reminders
最新稳定版本:v0.1.1
Composer 安装命令:
composer require befuturein/scheduled-reminders
包简介
Flexible scheduled reminders package for Laravel.
README 文档
README
BeFuture Scheduled Reminders is a simple, extensible, and reliable scheduled reminder package for Laravel. It stores reminders in the database, processes them when their scheduled time arrives, and dispatches an event so you can send notifications through any channel (email, SMS, push, database, etc.).
Features
- Create scheduled reminders easily
- Automatically resolve due reminders
- Prevent duplicate processing using
is_sentflag - Fully event-driven architecture
- Publishable config and migrations
- UUID-based model
- Service-based API
- Console command for the scheduler
- Complete Testbench integration
- PSR-4 & SOLID compliant structure
Installation
composer require befuturein/scheduled-reminders
Laravel automatically discovers the service provider.
Publish Config & Migrations
Run these commands inside your Laravel application:
php artisan vendor:publish --tag=scheduled-reminders-config php artisan vendor:publish --tag=scheduled-reminders-migrations php artisan migrate
Configuration
config/scheduled-reminders.php:
return [ 'default_channel' => 'email', 'channels' => [ 'email', 'database', 'sms', ], 'run_interval_minutes' => 5, ];
Scheduler Setup
Add to your scheduler:
// app/Console/Kernel.php protected function schedule(\Illuminate\Console\Scheduling\Schedule $schedule): void { $schedule->command('scheduled-reminders:send')->everyMinute(); }
Usage (Service API)
Create a reminder
use BeFuture\ScheduledReminders\Services\ReminderService; $reminder = app(ReminderService::class)->create([ 'title' => 'Payment Reminder', 'message' => 'Please don’t forget your monthly payment.', 'channel' => 'email', 'scheduled_at' => now()->addMinutes(10), ]);
Fetch due reminders
$due = app(ReminderService::class)->dueReminders();
Mark as sent
app(ReminderService::class)->markAsSent($reminder);
Event System
When a reminder is processed, this event is dispatched:
BeFuture\ScheduledReminders\Events\ReminderSent
Example listener:
class LogReminderSent { public function handle(ReminderSent $event) { logger('Reminder sent', [ 'id' => $event->reminder->id, ]); } }
Testing
This package includes full PHPUnit + Orchestra Testbench integration.
Run tests:
vendor/bin/phpunit
Example TestCase
abstract class TestCase extends BaseTestCase { use RefreshDatabase; protected function getPackageProviders($app): array { return [ ScheduledRemindersServiceProvider::class, ]; } protected function defineDatabaseMigrations() { $this->loadMigrationsFrom(__DIR__ . '/../database/migrations'); } }
Directory Structure
src/
ScheduledRemindersServiceProvider.php
Services/
Models/
Events/
Console/
config/
database/
tests/
composer.json
phpunit.xml.dist
README.md
Architecture
- Namespace:
BeFuture\ScheduledReminders - Vendor:
befuturein - Fully PSR-4 compliant
- UUID-based primary keys
- Service container bindings
- Event-driven flow
- Config-driven channel architecture
- Extensible by design for email, SMS, push, queue systems, etc.
Development
composer install vendor/bin/phpunit
License
MIT License.
About BeFuture Interactive
This package is part of the BeFuture Interactive open-source ecosystem. More packages coming soon.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-29