symfony/rocket-chat-notifier
Symfony Notifier bridge for Rocket.Chat. Configure a rocketchat:// DSN with incoming webhook token and default channel, then send ChatMessages. Supports custom payload (alias/avatar/channel overrides) and multiple attachments for rich messages.
RocketChatNotifier as a singleton or context-bound service, reducing boilerplate for message dispatch.rocketchat://TOKEN@HOST?channel=CHANNEL) mirrors Laravel’s .env pattern, enabling seamless integration with Laravel’s configuration system (e.g., config('services.rocket_chat')). This avoids hardcoding credentials or URLs.ChatMessage and RocketChatOptions classes can be extended to trigger RocketChat notifications from Laravel events (e.g., OrderShipped, UserRegistered) via listeners or queued jobs, enabling reactive workflows.#engineering for deployments, #support for tickets).NotificationGatewayInterface) would be required.HttpClient facade.$this->app->singleton(RocketChatNotifier::class, function ($app) {
return new RocketChatNotifier(
$app->make(HttpClient::class),
$app->config['services.rocket_chat.dsn']
);
});
.env:
ROCKET_CHAT_DSN=rocketchat://API_TOKEN@rocketchat.example.com?channel=general
notified:rocket-chat event).RocketChatOptions for richer payloads.HttpClient changes in Symfony 7).symfony/http-client:^6.4.)Notifier component) or use a wrapper?.env, Vault, or IAM?)AppServiceProvider:
public function register(): void
{
$this->app->singleton(RocketChatNotifier::class, function ($app) {
return new RocketChatNotifier(
new \Symfony\Contracts\HttpClient\HttpClient(),
config('services.rocket_chat.dsn')
);
});
}
RocketChat facade for cleaner syntax:
use Illuminate\Support\Facades\Facade;
class RocketChat extends Facade { protected static function getFacadeAccessor() { return 'rocket_chat'; } }
HttpClient with Guzzle:
use GuzzleHttp\Client;
$notifier = new RocketChatNotifier(new Client(), $dsn);
symfony/http-client package is installed (^6.4)..env variables:
ROCKET_CHAT_DSN=rocketchat://API_TOKEN@rocketchat.example.com?channel=general
ROCKET_CHAT_WEBHOOK_URL=https://rocketchat.example.com/hooks/WEBHOOK_ID
config/services.php:
'rocket_chat' => [
'dsn' => env('ROCKET_CHAT_DSN'),
'webhook_url' => env('ROCKET_CHAT_WEBHOOK_URL'),
],
#dev-alerts) to avoid noise.use Illuminate\Support\Facades\Event;
Event::listen(OrderShipped::class, function (OrderShipped $event) {
RocketChat::sendMessage(
'#support',
'New order shipped: #' . $event->order->id,
new RocketChatOptions([
['title' => 'Order Details', 'text' => $event->order->toJson()]
])
);
});
RocketChatOptions for consistency.symfony/http-client:^6.4 for Laravel 10+ compatibility.Notifier component) unless wrapped.symfony/http-client and symfony/notifier (if not already present)..env and config/services.php.RocketChatNotifier service provider.RocketChat::sendMessage()).try-catch blocks).How can I help you explore Laravel packages today?