symfony/fake-sms-notifier
Symfony Notifier transport that fakes SMS delivery during development. Redirect SMS messages to email (with configurable to/from and optional custom mailer transport) or log them via a logger DSN, without sending real texts.
symfony/mailer), introducing Symfony Notifier adds complexity and potential conflicts with Laravel’s existing notification system.email/logger) provide flexibility for debugging and QA.Notification facade with Symfony Notifier. This could involve:
Notification calls to Symfony Notifier.FAKE_SMS_DSN) aligns with Laravel’s .env pattern, reducing friction.// 1. Install dependencies
composer require symfony/notifier symfony/fake-sms-notifier
// 2. Configure in .env
FAKE_SMS_DSN=fakesms+email://default?to=dev@example.com&from=test-sms
// 3. Create a Laravel service to bridge Notifications
class FakeSmsService {
public function send(SmsNotification $notification) {
$notifier = new \Symfony\Component\Notifier\Notifier([
new \Symfony\Component\Notifier\Bridge\FakeSms\FakeSmsTransportFactory()
]);
$notifier->sendSms($notification->phone, $notification->message);
}
}
Notification system uses channels and events, while Symfony Notifier uses transports. Mapping these requires custom abstraction logic, increasing maintenance burden.via() method support for Laravel Notifications). May require forking or extending the package.laravel-notification-testing), teams may need to rewrite tests or adapt to new behavior.fakesms+logger, logs may clutter Laravel’s default channels. Consider a dedicated log channel (e.g., single or daily) for fake SMS.laravel-notification-testing or mocksms.Notification system to Symfony Notifier.Notification facade. Example architecture:
Laravel Notification Facade → Custom FakeSmsChannel → Symfony Notifier → FakeSmsTransport
laravel-notification-testing (for unit tests).Illuminate\Notifications\AnonymousNotifiable).via() method:
public function via($notifiable) {
return config('app.env') === 'local' ? ['fake_sms'] : ['nexmo'];
}
fakesms+logger first to avoid email routing complexities.if (app()->environment('local')) {
// Use FakeSmsService
} else {
// Use Twilio/AWS SNS
}
NEXMO_KEY vs. FAKE_SMS_DSN).fakesms+logger, configure Laravel’s logging to exclude fake SMS logs from production channels:
'channels' => [
'fake_sms' => [
'driver' => 'single',
'path' => storage_path('logs/fake_sms.log'),
'level' => 'debug',
],
],
symfony/notifier, symfony/fake-sms-notifier..env with FAKE_SMS_DSN.FakeSmsService).composer why-not to audit dependencies.Notification system evolves (e.g., new channel contracts).FAKE_SMS_DSN in production-like environments. Enforce checks:
if (app()->environment('production') && env('FAKE_SMS_DSN')) {
throw new \RuntimeException('Fake SMS enabled in production!');
}
fakesms+email://...).fakesms+logger to bypass email routing.How can I help you explore Laravel packages today?