rkingbishnoi/brevo-laravel-sdk
Composer 安装命令:
composer require rkingbishnoi/brevo-laravel-sdk
包简介
A Laravel package that provides an easy-to-use interface for interacting with Brevo's email, SMS, and marketing automation services, enabling seamless API integration for messaging and campaign management.
关键字:
README 文档
README
A Laravel package providing an easy-to-use interface for interacting with Brevo's email, SMS, and marketing automation services. This SDK enables seamless API integration for messaging and campaign management.
📌 Features
✅ Built on the Official Brevo PHP SDK
✅ Easy Brevo API Integration
✅ Support for Email, SMS, WhatsApp, and Campaign APIs
✅ Simple Laravel Facade for Quick Usage
✅ Built-in Exception Handling & API Validation
✅ Secure API Key Configuration
📦 Installation
Step 1: Install via Composer
You can install the package via Composer:
composer require rkingbishnoi/brevo-laravel-sdk
Step 2: Publish the Configuration
Publish the package configuration file to your application: bash Copy Edit
php artisan vendor:publish --tag=config
This will create a config/brevo.php file where you can set your Brevo API key.
Step 3: Set the API Key
Add your Brevo API key in your .env file:
BREVO_API_KEY=your-brevo-api-key
🚀 Usage Guide
Once you have installed and configured the package, you can start using it in your Laravel application.
This package provides a facade (Brevo) for interacting with various Brevo API services such as Transactional Emails, SMS, Contacts, and Campaigns.
📝 Quick Cheat Sheet
| Action | API Method | Example Usage 📌 |
|---|---|---|
| ✅ Send Transactional Email | Brevo::transactionalEmailsApi()->sendTransacEmail() | 📌 View Code |
| ✅ Send Transactional SMS | Brevo::transactionalSmsApi()->sendTransacSms() | 📌 View Code |
| ✅ Fetch Account Details | Brevo::accountApi()->getAccount() | 📌 View Code |
| ✅ Fetch Contact Lists | Brevo::listsApi()->getLists() | 📌 View Code |
| ✅ Send WhatsApp Message | Brevo::transactionalWhatsAppApi()->sendWhatsAppTemplateMessage() | 📌 View Code |
📧 Sending an Email via Brevo
use Rkingbishnoi\BrevoLaravelSdk\Facades\Brevo;
try {
$emailApi = Brevo::transactionalEmailsApi();
$response = $emailApi->sendTransacEmail([
'sender' => ['name' => 'Your Company', 'email' => 'your-email@yourdomain.com'],
'to' => [['email' => 'recipient@example.com', 'name' => 'Recipient Name']],
'subject' => 'Welcome to our platform!',
'htmlContent' => '<p>Hello, thank you for signing up!</p>',
]);
return response()->json(['success' => true, 'response' => $response]);
} catch (Exception $e) {
return response()->json(['error' => $e->getMessage()], 500);
}
🔥 Error Handling
This package comes with built-in exception handling for API-related issues.
Handling Missing API Key If the API key is missing, the package will throw:
throw new MissingApiKeyException('The Brevo API key is missing. Please set the [BREVO_API_KEY] in your .env file or config/brevo.php.');```
How to Handle?
use Rkingbishnoi\BrevoLaravelSdk\Facades\Brevo;
use Rkingbishnoi\BrevoLaravelSdk\Exceptions\MissingApiKeyException;
try {
$account = Brevo::accountApi()->getAccount();
} catch (MissingApiKeyException $e) {
return response()->json(['error' => $e->getMessage()], 400);
} catch (Exception $e) {
return response()->json(['error' => 'Something went wrong.'], 500);
}
Testing To run tests, use:
vendor/bin/phpunit
If you haven't installed Orchestra Testbench, install it with:
composer require --dev orchestra/testbench
Then run :
vendor/bin/phpunit
📄 License
This package is open-source software licensed under the MIT License.
📢 Contributing
We encourage and appreciate contributions! If you have any suggestions, improvements, or bug fixes, feel free to submit a pull request or start a discussion via issues.
📌 How to Contribute
- Fork the repository
- Create a new branch (
git checkout -b feature-branch) - Make your changes and ensure they follow best practices
- Commit your changes (
git commit -m "Describe your changes") - Push to your branch (
git push origin feature-branch) - Submit a pull request for review
🚀 Let's build something great together!
rkingbishnoi/brevo-laravel-sdk 适用场景与选型建议
rkingbishnoi/brevo-laravel-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 03 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「email marketing」 「laravel sms」 「laravel email」 「sms marketing」 「brevo」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rkingbishnoi/brevo-laravel-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rkingbishnoi/brevo-laravel-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rkingbishnoi/brevo-laravel-sdk 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Historical accounting for contacts
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.
Extends Mautic Lead Bundle's Lead List (Segment) functionality.
Sendrill DB
Pulls cost data from media advertising services.
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 24
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-03-19