- How do I install the Esendex SDK in a Laravel project?
- Run `composer require esendex/sdk:3.*` in your Laravel project directory. Ensure PHP 8.3+ and the cURL extension are enabled. The SDK will autoload via Composer’s autoloader, so no additional setup is needed beyond including the vendor autoloader.
- What Laravel versions does this SDK support?
- The SDK requires PHP 8.3+, which aligns with Laravel 10+. For Laravel 9 or older, you’ll need to downgrade PHP or use a compatible fork, as the SDK lacks backward compatibility for older PHP versions.
- How do I securely store Esendex API credentials in Laravel?
- Never hardcode credentials. Use Laravel’s `.env` file to store your Esendex account reference, email, and password. Bind them to the service container in `config/services.php` and resolve them dynamically in your service providers.
- Can I use Laravel Queues to defer SMS sends with this SDK?
- Yes. Wrap SDK calls in a Laravel Job (e.g., `SendSmsJob`) and dispatch it to the queue. This improves performance and scalability, especially for high-volume SMS notifications.
- Does the SDK handle Esendex’s rate limits or retries?
- The SDK does not natively handle rate limits or retries. Implement Laravel’s `Retryable` interface or use packages like `spatie/laravel-queue-retries` to manage failed SMS sends with exponential backoff.
- How can I test SMS sends without hitting Esendex’s API?
- Use Laravel’s `MockHttp` or `HttpTestResponse` to stub Esendex API calls in your feature tests. Mock the `DispatchService` or `InboxService` methods to return predefined responses, ensuring your logic works without real API calls.
- Is there a way to listen to Esendex webhooks (e.g., delivery reports) in Laravel?
- Yes. Configure Esendex to send webhooks to a Laravel route (e.g., `/esendex/webhook`). Use Laravel’s `HandleIncomingWebhook` trait or a dedicated controller to validate and process webhook payloads asynchronously.
- How do I integrate this SDK into a multi-tenant Laravel app?
- Scope SDK instances per tenant by dynamically resolving credentials from a tenant-specific table (e.g., `tenants`). Bind the `DispatchService` or `InboxService` to the container with tenant-aware authentication in your service provider.
- Are there alternatives to this SDK for Laravel SMS integration?
- Yes. Consider `vonage/client` (formerly Nexmo) or `twilio/sdk` for broader SMS/MMS support. For Esendex-specific needs, this SDK is lightweight but outdated; evaluate its API compatibility before adoption.
- How can I log SDK responses or errors in Laravel?
- Use Laravel’s logging facade (`Log::info()`) or integrate Monolog to log SDK responses, errors, or metrics. Wrap SDK calls in a service layer to centralize logging, e.g., `Log::debug('SMS sent', ['result' => $result->toArray()]).