spatie/mailcoach-sdk-php
PHP SDK for the Mailcoach API (self-hosted v6+ and Mailcoach Cloud). Manage email lists, subscribers, and campaigns: create and send campaigns, send tests, and browse paginated resources with an easy next() workflow.
Mailcoach instance binding). The Guzzle HTTP client dependency aligns with Laravel’s ecosystem (e.g., Http facade).spatie/mailcoach-sdk-php + guzzlehttp/guzzle)..env or vault).Mailcoach client to the container for singleton reuse.Mailcoach facade (e.g., Mailcoach::campaigns()) to mirror Laravel’s conventions.campaign.sent) via Laravel’s event system.email_lists, subscribers) locally for offline access or auditing.| Risk Area | Mitigation Strategy |
|---|---|
| API Rate Limits | Leverage the SDK’s built-in RateLimitedException and implement exponential backoff in Laravel’s HTTP client. |
| Pagination Handling | Use the SDK’s next() method carefully in loops; consider chunking for large datasets (e.g., 1000 items/page). |
| Data Consistency | Implement optimistic locking (e.g., ETag headers) or retry logic for concurrent updates. |
| Authentication | Store API keys in Laravel’s config/services.php or use a dedicated vault (e.g., HashiCorp Vault). |
| Version Compatibility | Pin the SDK version in composer.json to avoid breaking changes (Mailcoach API evolves independently). |
| Error Handling | Extend the SDK’s exceptions with Laravel’s App\Exceptions\Handler for user-friendly messages. |
NewsletterService)?GuzzleHttp\HandlerStack or Mockery.)Mailcoach client as a singleton in AppServiceProvider.Mailcoach facade for fluent syntax (e.g., Mailcoach::campaigns()->create(...)).CampaignSent, SubscriberConfirmed).subscribers) if offline access is needed..env (MAILCOACH_API_KEY, MAILCOACH_ENDPOINT).config/services.php for centralized configuration.createCampaign, subscribers()).campaign.sent).subscriber.confirmed).emailLists()).cURL and JSON extensions (standard in Laravel).^7.0) to avoid breaking changes.| Priority | Task | Dependencies |
|---|---|---|
| 1 | Install SDK and configure API credentials. | None |
| 2 | Implement basic CRUD operations (campaigns, subscribers). | SDK installation |
| 3 | Create Laravel facade and service layer. | Basic operations working |
| 4 | Add event dispatching for key actions. | Facade/service layer |
| 5 | Implement pagination handling for large datasets. | Basic operations |
| 6 | Add queue jobs for async operations. | Event system |
| 7 | Set up webhook listeners for real-time updates. | Mailcoach webhook configuration |
| 8 | Optimize with caching and local database sync. | Core functionality stable |
| 9 | Write integration tests. | All features implemented |
| 10 | Monitor and log API usage/metrics. | Production deployment |
spatie/mailcoach-sdk-php and guzzlehttp/guzzle for updates.composer.json ^ or ~ constraints to balance stability and updates.App\Exceptions\Handler).RateLimitedException).emailLists()).How can I help you explore Laravel packages today?