symfony/fake-chat-notifier
Symfony Fake Chat Notifier provides a fake chat transport for the Symfony Notifier component, ideal for local development and automated tests. Simulate sending chat messages without hitting real providers, with predictable, inspectable behavior.
Symfony\Component\FakeChatNotifier\FakeChatNotifierServiceProvider. This creates a loose coupling that aligns with Laravel’s extensibility (e.g., Notification facade, via() method).NotifierInterface, enabling runtime switching between fake and real channels. This is ideal for feature flags or environment-based configurations (e.g., app()->environment('local')).MailChannel, DatabaseChannel).vendor:publish and service container.Notification::send(), notifiable() trait) without modifying core logic. Existing via() methods can be extended to include FakeChatNotifier::class.fakechat+email://default?to=dev@example.com), which is familiar to Laravel developers using packages like laravel-horizon or laravel-queue.local, testing) to avoid accidental production use, aligning with Laravel’s App::environment() helper.NotifierInterface. Risk mitigated by Laravel’s PSR-11 container and interface-based DI.fake-chat-notifier.php), which may be overlooked. Mitigate with default values or environment variables (e.g., .env).if (!app()->isLocal()) return $realNotifier;).config('fake-chat-notifier.enabled')).FakeChannelInterface).Environment Strategy:
local, staging) to prevent production misuse?Testing Scope:
Notification::fake() alongside it.)assertLogged()) be implemented for fake notifications?Custom Channels:
Performance:
Migration Path:
Monitoring:
fake_chat.notifications channel)?Notification facade, via() method).FakeChatNotifierServiceProvider.symfony/notifier (v5.4+), which may add ~5MB to composer dependencies. Justify by:
assertLogged(), Mail::fake()).Phase 1: Local Development
AppServiceProvider:
if (app()->isLocal()) {
$this->app->bind(\Symfony\Component\Notifier\NotifierInterface::class, fn($app) =>
new \Symfony\Component\FakeChatNotifier\FakeChatNotifier($app->make(\Symfony\Component\Notifier\NotifierInterface::class))
);
}
Phase 2: Testing/QA
Phase 3: Production Readiness
'enabled' => env('FAKE_CHAT_ENABLED', false),
if (feature_enabled('real_chat_notifications')) {
return [SlackChannel::class];
}
return [FakeChatNotifier::class];
Mail, Database, Broadcast).FakeChannelInterface.NotifierInterface (e.g., custom notifier wrappers).symfony/notifier is installed (or add it to composer.json).config/notifications.php).composer require symfony/fake-chat-notifier symfony/notifier
php artisan vendor:publish --provider="Symfony\Component\FakeChatNotifier\FakeChatNotifierServiceProvider"
config/fake-chat-notifier.php to define channels (e.g., log, email).AppServiceProvider (environment-gated).assertLogged()).composer.json if stability is critical:
"symfony/fake-chat-notifier": "^7.4",
"symfony/notifier": "^5.4"
How can I help you explore Laravel packages today?