sendivent/sdk
Composer 安装命令:
composer require sendivent/sdk
包简介
Official PHP SDK for Sendivent - Multi-channel notification platform
README 文档
README
Official PHP SDK for Sendivent - Multi-channel notification platform supporting Email, SMS, Slack, Push, Telegram, WhatsApp, and Discord.
Installation
composer require sendivent/sdk
Requires PHP 8.1+ and Guzzle 7.0+
Quick Start
use Sendivent\Sendivent; $sendivent = new Sendivent('test_your_api_key_here'); $sendivent ->event('welcome') ->to('user@example.com') ->payload(['name' => 'John Doe']) ->send();
The SDK automatically routes to sandbox (test_*) or production (live_*) based on your API key prefix.
Response Object
The send() method returns a SendResponse object with helper methods:
$response = $sendivent ->event('invoice') ->to('user@example.com') ->payload(['amount' => 100]) ->send(); if ($response->isSuccess()) { echo $response->id; // "550e8400-e29b-41d4-a716-446655440000" } else { echo "Error: " . $response->error; } // Available properties: id, event, status, error // Available methods: isSuccess(), hasError(), toArray(), toJson()
The id is the notification identifier. Notifications are processed asynchronously — use GET /v1/notifications/{id} to track message status.
Fire-and-Forget
For background sending without waiting for the response:
$promise = $sendivent ->event('notification') ->to('user@example.com') ->payload(['message' => 'Hello']) ->sendAsync(); // Continue with other work... // Promise resolves in background
Contact Objects & Smart Detection
The to() method accepts strings, Contact objects, or arrays of either. Sendivent automatically detects what type of identifier you're sending:
// String inputs - automatically detected by pattern matching $sendivent->event('welcome')->to('user@example.com')->send(); // Detected as email $sendivent->event('sms-code')->to('+1234567890')->send(); // Detected as phone $sendivent->event('alert')->to('U12345')->send(); // Detected as Slack user ID // Contact objects - your user's ID maps to external_id in Sendivent $sendivent ->event('welcome') ->to([ 'id' => 'user-12345', // Your user's ID 'email' => 'user@example.com', 'phone' => '+1234567890', 'name' => 'John Doe', 'avatar' => 'https://example.com/avatar.jpg', 'meta' => ['tier' => 'premium'] ]) ->payload(['welcome_message' => 'Hello!']) ->send(); // Multiple recipients $sendivent ->event('newsletter') ->to([ 'user1@example.com', ['id' => 'user-456', 'email' => 'user2@example.com', 'name' => 'Jane'] ]) ->payload(['subject' => 'Monthly Update']) ->send(); // Broadcast to Slack channel (no contact created) $sendivent ->event('system-alert') ->channel('slack') ->to('#general') // Broadcasts to channel, doesn't create contact ->payload(['message' => 'System update']) ->send();
Key Features
- Multi-channel - Email, SMS, Slack, Push, Telegram, WhatsApp, and Discord in one API
- Fluent API - Clean, chainable method calls
- Type-safe - Full PHP 8.1+ type hints
- Fire-and-forget - Async sending with
sendAsync() - Idempotency - Prevent duplicate sends with
idempotencyKey() - Template overrides - Customize subject, sender, etc. per request
- Language support - Send in different languages with
language() - Channel control - Force specific channels with
channel() - Broadcast mode - Send to event listeners without specifying recipients
Additional Examples
Channel-Specific Sending
$sendivent ->event('verification-code') ->channel('sms') ->to('+1234567890') ->payload(['code' => '123456']) ->send();
Template Overrides
$sendivent ->event('invoice') ->to('user@example.com') ->payload(['amount' => 100]) ->overrides([ 'email' => [ 'subject' => 'Custom Subject', 'reply_to' => 'billing@company.com' ] ]) ->send();
Brand Overrides
$sendivent ->event('welcome') ->to('user@example.com') ->overrides([ 'brand' => ['logotype' => 'https://example.fi/logo.png'] ]) ->send();
Idempotency
$sendivent ->event('order-confirmation') ->to('user@example.com') ->payload(['order_id' => '12345']) ->idempotencyKey('order-12345-confirmation') ->send();
Language Selection
$sendivent ->event('welcome') ->to('user@example.com') ->payload(['name' => 'Anders']) ->language('sv') // Swedish ->send();
Broadcast Events
Send to configured event listeners without specifying recipients:
$sendivent ->event('system-alert') ->payload(['severity' => 'high', 'message' => 'System alert']) ->send();
Full Example
See example.php for a comprehensive demonstration of all SDK features.
Support
- Documentation: docs.sendivent.com
- Issues: github.com/sendivent/sdk-php/issues
License
MIT License - see LICENSE file for details.
sendivent/sdk 适用场景与选型建议
sendivent/sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 236 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 11 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「email」 「sms」 「notifications」 「slack」 「sendivent」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sendivent/sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sendivent/sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sendivent/sdk 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel Nova package that adds a notification feed in your Nova app.
SDK for payment gateway PlatbaMobilom.sk for PHP7.0
Extensible library for building notifications and sending them via different delivery channels.
Email+ extends Kirby's email capabilities by adding support for multiple email services using the same Kirby email API.
Captures outgoing SMS notifications
yii2-sms expand
统计信息
- 总下载量: 236
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-17