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.
Notification system relies on channels (e.g., MailChannel, NexmoChannel), whereas this package uses Symfony’s transport-based system. Bridging these requires custom abstraction layers, increasing complexity..env (e.g., FAKE_SMS_DSN=fakesms+email://default?to=dev@example.com).$notifier->sendSms($phone, $message)).Notification calls to Symfony Notifier. Example:
// app/Channels/FakeSmsChannel.php
use Symfony\Component\Notifier\Notifier;
use Illuminate\Notifications\Notification;
class FakeSmsChannel
{
public function __construct(private Notifier $notifier) {}
public function send($notifiable, Notification $notification)
{
$this->notifier->sendSms(
new \Symfony\Component\Notifier\Bridge\Sms\PhoneNumber($notifiable->phone),
$notification->toSms($notifiable)
);
}
}
via() method to dynamically switch between fake and real channels:
public function via($notifiable)
{
return app()->environment('local')
? ['fakesms'] // Custom channel
: ['nexmo']; // Real provider
}
laravel-notification-testing), this package may duplicate functionality or require parallel maintenance.laravel-notification-testing or similar, evaluate overlap and redundancy.Notification system to Symfony Notifier. This is feasible but non-trivial, adding maintenance overhead.NotificationFake may suffice for basic mocking.Notification::send(), custom services).fakesms+email and fakesms+logger transports.// app/Providers/NotificationServiceProvider.php
use Symfony\Component\Notifier\Notifier;
use App\Channels\FakeSmsChannel;
public function boot()
{
Notification::extend('fakesms', function ($app) {
return new FakeSmsChannel($app->make(Notifier::class));
});
}
.env:
FAKE_SMS_DSN=fakesms+email://default?to=dev@example.com&from=TestSMS
SMS_DRIVER=fake # or 'nexmo', 'aws', etc.
fakesms+logger transport uses Symfony’s Logger, which may not integrate seamlessly with Laravel’s Monolog. Consider custom log channels or dedicated log files.symfony/notifier and symfony/fake-sms-notifier to composer.json.FAKE_SMS_DSN in .env.via() methods in notifications to use the fake channel in dev.How can I help you explore Laravel packages today?