esendex/sdk
PHP 8.3+ SDK for Esendex SMS messaging. Install via Composer and authenticate with your account to send SMS and retrieve inbox messages. Includes dispatch and inbox services, uses cURL, and supports autoloading via Composer or bundled loader.
DispatchMessage, InboxMessage) align with DDD principles, enabling clean integration into Laravel’s service layer or repositories.SmsSent, SmsFailed) via SDK callbacks or post-send webhooks (Esendex supports this).Sms::send()) for consistency with existing codebase patterns.User table) for tracking or retries..env + Laravel’s config/services.php.DispatchService, InboxService) as singletons with resolved credentials.SmsSent with message metadata).SendSmsJob) for async processing.class SendSmsJob implements ShouldQueue {
public function handle() {
$service = app(Esendex\DispatchService::class);
$result = $service->send($this->message);
event(new SmsSent($result));
}
}
MockHttp or HttpTestResponse to stub Esendex API calls in feature tests.$this->mockEsendexApi()
->shouldReceive('send')
->once()
->andReturn(new Esendex\Model\Result("123"));
SmsController).SmsService facade wrapping SDK methods.class SmsService {
public function __construct(private DispatchService $dispatch) {}
public function send(string $to, string $message): string {
$dispatchMsg = new \Esendex\Model\DispatchMessage(
config('services.esendex.originator'),
$to,
$message,
\Esendex\Model\Message::SmsType
);
return $this->dispatch->send($dispatchMsg)->id();
}
}
Retryable interface or spatie/laravel-queue-retries).monolog/monolog for SDK responses).SmsSent event failures).ext-curl is enabled (Laravel’s default)..env:
ESENDEX_ACCOUNT=EX000000
ESENDEX_USERNAME=user@example.com
ESENDEX_PASSWORD=secret
ESENDEX_ORIGINATOR=YourApp
EsendexServiceProvider) in config/app.php.SmsService.composer.json to avoid surprises (e.g., 3.0.0).config/services.php to externalize credentials:
'esendex' => [
'account' => env('ESENDEX_ACCOUNT'),
'username' => env('ESENDEX_USERNAME'),
'password' => env('ESENDEX_PASSWORD'),
],
rotate-esendex-credentials Artisan command.result->errors()) to debug failures.support@esendex.com).InboxService::latest() parameters).retry helper or spatie/laravel-queue-retries).Esendex\InboxService::latest()).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Esend |
How can I help you explore Laravel packages today?