skaisser/larasendy

A Laravel package to integrate Sendy.co for email subscriptions automatically to all your Laravel installations

v1.2.4 2024-11-27 06:09 UTC

This package is auto-updated.

Last update: 2024-12-27 06:19:51 UTC


README

Latest Version on Packagist Total Downloads Tests License

A Laravel package for seamless integration with Sendy email marketing platform.

Features

  • 🔄 Automatic subscriber synchronization with Sendy
  • 🎯 Flexible field mapping
  • 🚀 Artisan command for bulk synchronization
  • 🔍 Event-driven architecture
  • 💾 Cache-based tracking
  • ⚡ Efficient chunk processing
  • 🛡️ Error handling and logging

Laravel Support

Requirements

  • PHP 7.4+
  • Laravel 6.0 - 10.0
  • Sendy installation

Installation

composer require skaisser/larasendy

Configuration

Publish the configuration file:

php artisan vendor:publish --provider="Skaisser\LaraSendy\LaraSendyServiceProvider"

Configure your .env file:

SENDY_URL=your-sendy-installation-url
SENDY_API_KEY=your-api-key
SENDY_LIST_ID=your-list-id

Usage

Basic Setup

  1. Add the SendySubscriber trait to your User model:
use Skaisser\LaraSendy\Traits\SendySubscriber;

class User extends Model
{
    use SendySubscriber;
}
  1. Configure field mapping in config/sendy.php:
'fields_mapping' => [
    'email' => 'email',
    'name' => 'name',
    'company' => 'company',
    'country' => 'country'
]

Automatic Synchronization

The package automatically syncs users when they are:

  • Created
  • Updated
  • Deleted (configurable behavior)

Manual Synchronization

Use the artisan command to sync all subscribers:

php artisan sendy:sync

Events

The package dispatches events that you can listen to:

  • SendySubscriberSynced: When a subscriber is successfully synced
  • SendySubscriberFailed: When sync fails

Cache Management

Sync status is tracked in cache:

  • Success: sendy_sync_status_{id}
  • Errors: sendy_sync_error_{id}

Testing

composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email the author instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.