symfony/google-chat-notifier
Symfony Notifier integration for Google Chat. Configure a googlechat:// DSN with access key/token and target space, optionally providing a thread_key to group messages into a single thread.
Symfony Ecosystem Synergy:
EventDispatcher is compatible but requires adapter abstraction (e.g., wrap Symfony’s EventDispatcher or use a facade).GoogleChatTransport) or use a Symfony microkernel for the Notifier component.Bus to dispatch notifications via a GoogleChatChannel.Decoupling and Scalability:
Notification Richness:
thread_key). Ideal for alerting, incident management, or workflow automation.@mentions or DMs).| Risk | Impact | Mitigation Strategy |
|---|---|---|
| Symfony Dependency Bloat | Adds ~5MB to Laravel app; potential version conflicts. | Use Composer’s replace to avoid pulling full Symfony stack. Extract only GoogleChatTransport. |
| Laravel-Symfony Bridge | Event dispatching or Notifier integration may break. | Abstract behind interfaces (e.g., NotificationTransportInterface) for swappability. |
| Google Chat API Changes | Breaking changes in Google’s API. | Use Symfony’s HttpClient middleware for retries/timeouts. Monitor Google’s deprecations. |
| Thread Key Management | Manual thread_key handling risks message sprawl. |
Implement database-backed thread mapping (e.g., thread_key per incident type). |
| Rate Limiting | Exceeding Google Chat quotas. | Add exponential backoff in Laravel’s queue worker or Symfony’s HttpClient. |
| Testing Complexity | Mocking HTTP calls for unit tests. | Use Symfony’s HttpClientMock or Laravel’s MockHttpClient for isolated testing. |
Stack Compatibility:
Authentication:
ACCESS_KEY/ACCESS_TOKEN be secured? (e.g., .env, Vault, or service account?)Threading Strategy:
thread_key be managed? (e.g., static per-channel, dynamic per-incident, or database-driven?)Failure Modes:
Scaling:
Maintenance:
Symfony Applications:
symfony/notifier with the GoogleChatTransport DSN.# config/packages/notifier.yaml
framework:
notifier:
transports:
google_chat:
dsn: '%env(GOOGLE_CHAT_DSN)%'
options:
thread_key: 'incident_%kernel.environment%'
$this->notifier->info(new GoogleChatMessage('Deployment failed!', 'thread_123'));
Laravel Applications:
GoogleChatTransport from the package and wrap it in a Laravel service.// app/Services/GoogleChatNotifier.php
use Symfony\Component\Notifier\Transport\GoogleChatTransport;
class GoogleChatNotifier
{
public function __construct(private string $dsn) {}
public function send(string $message, ?string $threadKey = null): void
{
$transport = new GoogleChatTransport($this->dsn, [
'thread_key' => $threadKey,
]);
$message = new GoogleChatMessage($message);
$notifier = new \Symfony\Component\Notifier\NotifierInterface();
$notifier->info($message)->transport($transport)->send();
}
}
AppServiceProvider:
$this->app->singleton(GoogleChatNotifier::class, function ($app) {
return new GoogleChatNotifier(config('services.google_chat.dsn'));
});
symfony/event-dispatcher and symfony/http-client.EventDispatcher facade to bridge events.// app/Providers/EventServiceProvider.php
use Symfony\Component\EventDispatcher\EventDispatcher;
public function boot()
{
$dispatcher = new EventDispatcher();
$dispatcher->addListener('user.registered', function ($event) {
$notifier = new \Symfony\Component\Notifier\NotifierInterface();
$notifier->info(new GoogleChatMessage('New user registered!'))->send();
});
}
Phase 1: Proof of Concept (1–2 Days)
#dev-alerts).thread_key and basic messages.Phase 2: Core Integration (3–5 Days)
GoogleChatNotifier service and integrate with Events/Queues.notifier.yaml and dispatch notifications from controllers/services.Phase 3: Advanced Features (1 Week)
thread_key (e.g., per-incident or per-workflow).Phase 4: Monitoring and Scaling
| Component | Laravel Compatibility | Symfony Compatibility | Notes |
|---|---|---|---|
| DSN Configuration | ✅ (via .env) |
✅ (via services.yaml) |
Use GOOGLE_CHAT_DSN in Laravel or %env(GOOGLE_CHAT_DSN)% in Symfony. |
| Event Dispatching | ⚠️ (requires bridge) | ✅ (native) | Laravel needs symfony/event-dispatcher or custom |
How can I help you explore Laravel packages today?