定制 nextmigrant/laravel-sendy 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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.enabled config value. When set to false (via SENDY_ENABLED=false in your .env), methods return null (or [] for getLists) 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 我们能提供哪些服务?
定制开发 / 二次开发

基于 nextmigrant/laravel-sendy 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 66
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 25
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-06