- How do I install the MailerLite PHP SDK in a Laravel application?
- Install it with Composer using composer require mailerlite/mailerlite-php. The SDK is framework-agnostic, so Laravel will not auto-register a service provider or config file. Create a small service or bind the client in a service provider, and pass your MailerLite API key from config/services.php or an environment variable.
- Does mailerlite/mailerlite-php support Laravel 10 and Laravel 11?
- The package is a plain PHP SDK rather than a Laravel package, so it is not tied to a specific Laravel release. It can be used in Laravel 10, Laravel 11, or other versions that satisfy its PHP and PSR-7/PSR-18 dependency constraints. Check the Composer requirements and test your HTTP client setup before upgrading Laravel.
- Do I need a service provider or config file for MailerLite in Laravel?
- No, the SDK does not ship a Laravel service provider, facade, or publishable config. You should add your own binding, such as in AppServiceProvider, and store the API key in config/services.php or the environment. Wrapping the client in an application service keeps controllers clean and makes testing easier.
- What can I manage with the MailerLite PHP SDK?
- The SDK covers subscribers, campaigns, groups, segments, fields, forms, automations, webhooks, campaign languages, timezones, and batch requests. It provides methods for common create, read, update, and delete operations across those resources. It is an API client, so your Laravel app still owns authorization, validation, local persistence, and business workflows.
- How do I receive MailerLite webhooks in Laravel?
- Use the SDK's webhook resource to create and manage the webhook subscription in MailerLite, then expose a Laravel route that accepts the incoming payload. Put processing into queued jobs and make handlers idempotent because webhook delivery and retries can overlap. The SDK helps manage webhook records; receiving, validating, and reconciling events is application-level code.
- Is $subscriber->forget safe to use in production?
- Treat it as a potentially destructive erasure operation and require explicit authorization, confirmation, audit logging, and environment guards before calling it. Run it through a queued job so failures are isolated and retries are controlled, and make the workflow idempotent. Also verify the exact MailerLite API semantics and test missing, already-forgotten, unauthorized, and transient failure cases.
- How should I test MailerLite API calls in Laravel?
- Wrap the SDK behind your own service interface and mock that interface in feature tests, or inject a mock PSR-18 HTTP client for lower-level contract tests. Cover success, unauthorized, not-found, rate-limit, API failure, and retry behavior, especially around subscriber deletion or forget. Use a MailerLite sandbox or test account where possible, and keep destructive cleanup tests isolated.
- What are the main production risks of using this SDK?
- The SDK depends on MailerLite API availability, rate limits, and upstream response semantics, so transient failures and throttling need retry and backoff handling. Irreversible subscriber operations create deletion and compliance risk, and partial failures can leave MailerLite and local records inconsistent. Define a source of truth, reconcile via webhooks or scheduled syncs, and log all destructive actions.
- Are there Laravel-specific alternatives to mailerlite/mailerlite-php?
- The official SDK is not Laravel-specific, so any Laravel wrapper or community package should be compared on maintenance, feature parity, and support for webhooks and subscriber forget. Many teams prefer a thin application service around the official SDK to avoid losing official API coverage. Evaluate whether an alternative actually reduces complexity or just adds another dependency.
- How do I keep a MailerLite integration maintained over time?
- Track MailerLite API changelogs and the package's releases, and update Composer dependencies deliberately with regression tests. Keep contract tests for subscribers, webhooks, rate limits, and deletion semantics, and monitor failures in production. Periodically review deprecations, local retention rules, and whether your service wrapper still matches how the SDK is used.