designbycode/laravel-brevo
Composer 安装命令:
composer require designbycode/laravel-brevo
包简介
wrapper for brevo-php
README 文档
README
The LaravelBrevo package is a Laravel wrapper for integrating with the Brevo API (formerly Sendinblue). It simplifies interactions with Brevo's email marketing and contact management features, allowing you to manage contacts, subscribe/unsubscribe users, and retrieve contact information seamlessly within your Laravel application.
This version of the documentation demonstrates how to use the package via the Facade for cleaner and more expressive code.
Use Cases
This package is ideal for:
-
Email Marketing:
- Subscribe users to mailing lists.
- Unsubscribe users from mailing lists.
- Update user attributes (e.g., name, preferences).
-
Contact Management:
- Retrieve contact details.
- Create or update contacts in Brevo.
-
Automation:
- Automatically add new users to Brevo lists during registration.
- Sync user data between your application and Brevo.
Support us
Installation
You can install the package via composer:
composer require designbycode/laravel-brevo
You can publish the config file with:
php artisan vendor:publish --tag="brevo"
Add your Brevo API key to the .env file:
BREVO_API_KEY=your-api-key
Configuration
return [ 'api_key' => env('BREVO_API_KEY', ''), ];
api_key: Your Brevo API key. This is required to authenticate API requests.
Usage
Retrieve Contact Information.
To retrieve details for a specific contact by email:
use Designbycode\LaravelBrevo\Facades\Brevo; if ($contact = Brevo::getContactInfo('test@example.com')) { echo "Contact Name: " . $contact->getAttributes()->name; } else { echo "Contact not found."; }
Subscribe a Contact
To subscribe a contact to a mailing list:
use Designbycode\LaravelBrevo\Facades\Brevo; if ($success = Brevo::subscribe('test@example.com', $listId)) { echo "Contact subscribed successfully!"; } else { echo "Failed to subscribe contact."; }
Unsubscribe a Contact
To unsubscribe a contact from a mailing list:
use Designbycode\LaravelBrevo\Facades\Brevo; if ($success = Brevo::unsubscribe('test@example.com', $listId)) { echo "Contact unsubscribed successfully!"; } else { echo "Failed to unsubscribe contact."; }
Methods
Brevo::getContactInfo(string $email): ?GetExtendedContactDetails
- Retrieves contact details for the specified email.
- Returns
nullif the contact is not found.
Brevo::subscribe(string $email, int $listId, array $attributes = []): bool
- Subscribes a contact to a mailing list.
- Creates a new contact if they don't exist, or updates an existing contact.
- Returns
trueon success,falseon failure.
Brevo::unsubscribe(string $email, int $listId): bool
- Unsubscribes a contact from a mailing list.
- Returns
trueon success,falseon failure.
Error Handling
The package handles API errors gracefully:
- 404 Not Found: Logs a warning and returns
nullorfalse. - 500 Server Error: Logs an error and returns
false. - Other exceptions are logged and handled appropriately.
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
designbycode/laravel-brevo 适用场景与选型建议
designbycode/laravel-brevo 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 29 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 01 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「designbycode」 「laravel-brevo」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 designbycode/laravel-brevo 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 designbycode/laravel-brevo 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 designbycode/laravel-brevo 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The Luhn Algorithm is a simple checksum formula used to validate a variety of identification numbers, such as credit card numbers, IMEI numbers, and others. This documentation provides an overview of the Luhn Algorithm implementation in PHP, including examples and use cases.
The Business Name Generator is a PHP class that generates business names based on a combination of adjectives and nouns. It provides a flexible and customizable way to generate business names that can be used for various purposes.
Alfabank REST API integration
The Reviews class is a part of the Designbycode namespace and is used to fetch reviews, rating, and user ratings total of a place using the Google Places API. It requires a Google Maps API key and a Google Maps place ID to make requests.
The LevenshteinDistance class provides a method to calculate the Levenshtein distance between two strings. The Levenshtein distance is a measure of the minimum number of single-character edits (insertions, deletions, or substitutions) required to change one word into the other.
The South African ID Validator is a PHP class that validates and extracts information from South African ID numbers. It uses the Luhn Algorithm to validate the ID number and provides methods to determine the gender, citizenship, and birthdate of the individual.
统计信息
- 总下载量: 29
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-01-22