nextmigrant/laravel-sendy
Composer 安装命令:
composer require nextmigrant/laravel-sendy
包简介
A generic Sendy email marketing API client for Laravel
README 文档
README
A reusable Laravel package that wraps the Sendy self-hosted email marketing API. It provides a clean SendyService class for subscribing/unsubscribing users, managing list membership, querying subscription statuses and active counts, and retrieving brand lists — all with a built-in production environment guard so no real API calls are ever made during development or testing.
Supports Laravel 10, 11, 12, and 13 with PHP 8.3+.
Installation
composer require nextmigrant/laravel-sendy
Optionally publish the config file:
php artisan vendor:publish --tag=sendy-config
This creates config/sendy.php. You can also set everything via environment variables:
| Variable | Description |
|---|---|
SENDY_ENABLED |
Enable or disable all API calls (default: true). Set to false in local/staging. |
SENDY_API_KEY |
Your Sendy installation API key |
SENDY_URL |
Base URL of your Sendy installation (e.g. https://sendy.yourdomain.com) |
SENDY_NEW_USERS_LIST_ID |
List ID for the default "new signups" list |
Usage
You can use the Sendy facade or inject/instantiate SendyService directly:
use NextMigrant\Sendy\Facades\Sendy; // Via facade $response = Sendy::subscribe('john@example.com', 'list-abc', 'John', 'Doe');
use NextMigrant\Sendy\SendyService; // Via direct instantiation $sendy = new SendyService; $response = $sendy->subscribe('john@example.com', 'list-abc', 'John', 'Doe'); // Or via dependency injection (registered as a singleton) public function __construct(private SendyService $sendy) {}
Note: All methods are guarded by the
sendy.enabledconfig value. When set tofalse(viaSENDY_ENABLED=falsein your.env), methods returnnull(or[]forgetLists) without making any API calls.
Subscribe
$response = $sendy->subscribe( email: 'john@example.com', listId: 'your-list-id', firstName: 'John', lastName: 'Doe', ); // With optional full name and custom fields $response = $sendy->subscribe( email: 'john@example.com', listId: 'your-list-id', firstName: 'John', lastName: 'Doe', fullName: 'Dr. John Doe', options: [ 'country' => 'CA', 'gdpr' => 'true', 'Birthday' => '1990-01-15', ], );
Unsubscribe
$response = $sendy->unsubscribe('john@example.com', 'your-list-id');
Delete Subscriber
$response = $sendy->deleteSubscriber('john@example.com', 'your-list-id');
Get Subscription Status
$response = $sendy->getSubscriptionStatus('john@example.com', 'your-list-id'); // $response->message will be one of: // Subscribed, Unsubscribed, Unconfirmed, Bounced, Soft bounced, Complained
Get Active Subscriber Count
$response = $sendy->getActiveSubscriberCount('your-list-id'); // $response->message contains the count as a string (e.g. "1523")
Get Lists
$lists = $sendy->getLists(brandId: 1); // Returns: [['id' => 1, 'name' => 'Newsletter'], ...] // Include hidden lists $lists = $sendy->getLists(brandId: 1, includeHidden: true);
Response Object
All methods (except getLists) return a SendyResponse DTO:
use NextMigrant\Sendy\SendyResponse; $response->success; // bool $response->message; // string — "1" on success, or an error message
The static factory SendyResponse::fromApiResponse(string $body) treats "1" and "true" (case-insensitive) as success.
Testing
composer test
License
MIT
nextmigrant/laravel-sendy 适用场景与选型建议
nextmigrant/laravel-sendy 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 66 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「Sendy」 「email-marketing」 「nextmigrant」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 nextmigrant/laravel-sendy 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nextmigrant/laravel-sendy 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 nextmigrant/laravel-sendy 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Sendy API implementation for Laravel
A PHP Library for interfacing with the Sendy newsletter system (http://sendy.co)
PHP class for using sendy API
Official PHP SDK for the Quentn Api
Build and execute an OpenSearch search query using a fluent PHP API
A PHP package for interacting with the ActiveCampaign API v3
统计信息
- 总下载量: 66
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 25
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-06