artox-lab/clarc-notification-bundle
NotifierInterface to Laravel’s service container (e.g., via bind() in AppServiceProvider).config/app.php for service providers, not bundles. The ArtoxLabClarcNotificationBundle must be adapted to a Laravel service provider.Transport interface could leverage Laravel’s queue workers, mail drivers, or third-party APIs (e.g., Twilio for SMS, Mailgun for email) with custom adapters.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Symfony-Laravel Gap | High | Abstract Symfony dependencies (e.g., FrameworkBundle) behind interfaces. |
| Configuration Mismatch | Medium | Replace YAML configs with Laravel’s config/notification.php or env vars. |
| Event System Conflict | Medium | Decide: Use Laravel’s events or the bundle’s notifier (not both). |
| Testing Overhead | Low | Mock NotifierInterface and Transport interfaces in PHPUnit. |
| Performance | Low | Benchmark queue-based vs. direct transport calls (Laravel’s queues are optimized). |
Illuminate\Notifications instead.Transport implementations will be needed for unsupported channels.config/, env vars, or a database-backed solution.bundles.php with a Laravel Service Provider (ClarcNotificationServiceProvider) to bind NotifierInterface and Transport implementations.config/notification.php to define transports (email, SMS, etc.) instead of Symfony YAML.NotificationSent).Mailable or SwiftMailer via a custom EmailTransport.notifications channel or use a package like vonage/cloud via SmsTransport.HttpClient for the existing HttpTransport support.Notification entity to Laravel’s Eloquent models or value objects (e.g., App\Models\Notification).Phase 1: Interface Adaptation
// app/Providers/ClarcNotificationServiceProvider.php
public function register()
{
$this->app->bind(
NotifierInterface::class,
ClarcNotifier::class // Custom Laravel implementation
);
$this->app->bind(
TransportInterface::class,
EmailTransport::class // Default transport
);
}
ClarcNotifier to delegate to Laravel’s Bus or Queue system.Phase 2: Transport Implementation
Transport:
class EmailTransport implements TransportInterface
{
public function send(Notification $notification, EmailRecipient $recipient)
{
Notification::send($recipient->email, new MailableNotification($notification));
}
}
Phase 3: Configuration
// config/notification.php
return [
'transports' => [
'email' => [
'driver' => 'mailgun',
'key' => env('MAILGUN_KEY'),
],
'sms' => [
'driver' => 'twilio',
'sid' => env('TWILIO_SID'),
],
],
];
Phase 4: Usage
NotifierInterface into services and use as shown in the README, but with Laravel’s DI:
public function __construct(private NotifierInterface $notifier) {}
public function notify()
{
$this->notifier->notify(
new ExampleNotification('test'),
new SmsRecipient('+123123123'),
new EmailRecipient('test@example.com')
);
}
| Component | Laravel Equivalent | Notes |
|---|---|---|
bundles.php |
AppServiceProvider |
Replace bundle registration with service binding. |
| Symfony YAML Config | config/notification.php or .env |
Use Laravel’s configuration system. |
NotifierInterface |
Laravel’s Bus or custom facade |
Can wrap Laravel’s Notification facade or use queues. |
Transport |
Laravel’s Mailer, HttpClient, etc. |
Custom adapters required for non-native channels. |
| Event Dispatching | Laravel’s Event system |
Optional: Dispatch events when notifications are sent. |
Illuminate\Notifications.NotifierInterface and one Transport (e.g., email).Illuminate\Notifications; this adds another layer.telescope or laravel-debugbar.Log facade or custom monitoring.Exception handling for transport failures (e.g., SMS delivery errors).FailedJob table for queue-based transports.laravel-notification.md with Laravel-centric examples.dispatch() notifications).Batch jobs for bulk notifications.Transport implementations (e.g., HTTP, email) scale horizontally.How can I help you explore Laravel packages today?