michael-orenda / notification
Enterprise-grade notification package providing email, SMS, in-app, push, and webhook channels with hybrid Blade/DB templates and Logging integration.
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/michael-orenda/notification
Requires
- php: >=8.2
- illuminate/database: ^12.0
- illuminate/mail: ^12.0
- illuminate/notifications: ^12.0
- illuminate/support: ^12.0
- michael-orenda/logging: ^1.0 || dev-main
README
A production-grade, auditable, queue-safe notification system for Laravel.
This package is designed for reliability, traceability, and clarity, not magic. If you forget how it works in 6 months — read this file and you’ll be productive again.
Table of Contents
- Overview & Philosophy
- Architecture & Mental Model
- Supported Channels
- Template System (DB → Blade → Inline)
- Standard Template Keys
- Installation
- Configuration
- Usage Examples
- Queueing & Retry Behavior
- Logging & Auditing
- Seeders & Default Templates
- Blade Templates (Fallbacks)
- What This Package Does NOT Do
- Production Checklist
1. Overview & Philosophy
This package treats notifications as delivery intents, not just messages.
- Delivery is observable
- Failures are audited
- Retries are intentional
- Templates are versioned
- Channels are isolated
This is suitable for:
- Financial systems
- Security alerts
- Compliance-heavy domains
- Multi-channel delivery (Email, SMS, Slack, In-App)
2. Architecture & Mental Model
Core Components
- Notifier → Orchestrates delivery (sync vs queue)
- SendNotificationJob → Async execution + retries
- Channels → Email, SMS, Slack, In-App
- NotificationTemplate → Versioned content (DB)
- Blade Templates → File-based fallback
- NotificationLogger → Single source of audit truth
Template Resolution Order
- Database template
- Published Blade template (host app)
- Package Blade template
- Inline body (last resort)
3. Supported Channels
| Channel | Purpose |
|---|---|
| Rich HTML, long-form | |
| SMS | Short, urgent alerts |
| In-App | UI notifications |
| Slack | Ops / Dev alerts |
4. Template System
Templates are channel-specific and versioned.
Database columns:
keychannelsubject(nullable)bodyversion
Never edit templates in-place. Increment the version instead.
5. Standard Template Keys
System
system.criticalsystem.warningsystem.info
Authentication
auth.otpauth.login_alertauth.password_reset
User Lifecycle
user.welcomeuser.profile_updateduser.deactivated
Security
security.suspicious_loginsecurity.password_changed
Business (Generic)
transaction.successtransaction.faileddocument.ready
6. Installation
composer require michael-orenda/notification
Publish config (optional):
php artisan vendor:publish --tag=notification-config
7. Configuration
Queueing
'queue' => env('NOTIFICATION_QUEUE', false), 'queue_name' => 'notifications',
Retry & Backoff
'retry' => [ 'count' => 5, 'backoff' => [1, 3, 5, 10, 20], ],
Per-channel overrides
'sms' => [ 'retries' => 6, 'backoff' => [1, 3, 5, 10, 20], ],
8. Usage Examples
Basic Send
use MichaelOrenda\Notification\Services\Notifier; $notifier->send( $user, 'system.critical', [ 'content' => 'Disk usage exceeded 95%', 'server' => 'prod-01', ], ['email', 'sms'] );
Inline Body (no template)
$notifier->send($user, [ 'body' => 'Simple text message', ], [], ['sms']);
9. Queueing & Retry Behavior
When NOTIFICATION_QUEUE=true:
- Notifications are dispatched to a queue
- Retries are attempt-based
- Exponential backoff is applied
- Highest-risk channel controls retry behavior
Run worker:
php artisan queue:work --queue=notifications
10. Logging & Auditing
All delivery attempts are stored in:
notification_deliveries
Each record includes:
- channel
- provider
- destination
- template key + version
- status (
sent,failed) - error (if any)
This table is your audit trail.
11. Seeders & Default Templates
A default seeder is provided:
MichaelOrenda\Notification\Database\Seeders\NotificationTemplateSeeder
Run:
php artisan db:seed --class="MichaelOrenda\\Notification\\Database\\Seeders\\NotificationTemplateSeeder"
This seeds:
- Email templates
- SMS templates
- In-App templates
- Slack templates
12. Blade Templates (Fallback)
Package fallbacks live in:
resources/views/emails/
resources/views/sms/
resources/views/slack/
Host apps may override by publishing views.
13. What This Package Does NOT Do
Intentionally excluded:
- ❌ UI rendering
- ❌ User preference screens
- ❌ Cron-based scheduling
- ❌ Marketing campaigns
Those belong in higher-level packages.
14. Production Checklist
Before shipping:
- Enable queue mode
- Configure retries & backoff
- Seed templates
- Start queue workers
- Monitor
notification_deliveries
Final Note
This package favors correctness over convenience.
If something fails:
- You will know
- You will have logs
- You will not lose notifications
Ship with confidence.