warksit/laravel-mail-chimp-sync
Composer 安装命令:
composer require warksit/laravel-mail-chimp-sync
包简介
Sync Laravel Models with MailChimp as Members or Interests
README 文档
README
A package to sync subscribers and interests (using eloquent events) with MailChimp (API v3) for Laravel 5.2+. It's only dependency is Guzzle 6 or 7.
Installation
To get started, require this package:
composer require warksit/laravel-mail-chimp-sync
Add the ServiceProvider in config/app.php:
'providers' => [ ... Warksit\LaravelMailChimpSync\MailingListServiceProvider::class, ],
Next run vendor:publish to copy the migrations.
php artisan vendor:publish --provider="Warksit\LaravelMailChimpSync\MailingListServiceProvider"
Run the migrations:
php artisan migrate
Usage
This package has 2 main uses. It syncs subscribers to a list(s) and syncs a list of interests of an interest group(s). It makes use of eloquent events to detect changes and also makes use of queued jobs so the relative expensive calls to MailChimp don't slow your program flow. The one exception is deleting a model as we need to remove that from MailChimp while the record still exists.
Sync Subscribers
This allows you to keep changes you make to an Eloquent Model in sync with a MailChimp List. It uses eloquent events. This is achieved through the Warksit\LaravelMailChimpSync\EloquentTraits\MailChimpSyncMember trait. This requires a few methods on the model which are enforced by implementing the Warksit\LaravelMailChimpSync\EloquentTraits\CanSyncMailChimpMember interface. Have a look in the doc blocks for more details. If you have overidden the boot() method make sure you call parent::boot() no worries if you haven't.
use Warksit\LaravelMailChimpSync\Interfaces\CanSyncMailChimpMember; use Warksit\LaravelMailChimpSync\EloquentTraits\MailChimpSyncMember; class YourModel extends Model implements CanSyncMailChimpMember { use MailChimpSyncMember protected static function boot() { parent::boot(); ... } }
Sync Interest
This allows you to keep changes you make to an Eloquent Model in Sync as the Interest for an Interest Group. This is achieved through the Warksit\LaravelMailChimpSync\EloquentTraits\MailChimpSyncInterest trait. This requires a few methods on the model which are enforced by implementing the Warksit\LaravelMailChimpSync\EloquentTraits\CanSyncMailChimpInterest interface. Have a look in the doc blocks for more details. Again if you have overidden the boot() method make sure you call parent::boot() no worries if you haven't.
use Warksit\LaravelMailChimpSync\Interfaces\CanSyncMailChimpInterest; use Warksit\LaravelMailChimpSync\EloquentTraits\MailChimpSyncInterest; class YourInterestModel extends Model implements CanSyncMailChimpInterest { use MailChimpSyncInterest; protected static function boot() { parent::boot(); ... } }
Manual Sync
If you would like to trigger a sync for a model at another time just call $memberModel->mailingListSubscribe() to resync a member or $interestModel->addInterestGroup() on the relevant model. This is particularly useful to add a new interest to a member.
Contributing
Please! This meets my needs but am open to help. If you find an issue, or have a better way to do something, open an issue or a pull request. There are some tests. To get the integration tests to work copy .env.example to .env and enter your MailChimp credentials.
warksit/laravel-mail-chimp-sync 适用场景与选型建议
warksit/laravel-mail-chimp-sync 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.24k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2016 年 07 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 warksit/laravel-mail-chimp-sync 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 warksit/laravel-mail-chimp-sync 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.24k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-07-04