PHP code example of banulakwin / laravel-sms

1. Go to this page and download the library: Download banulakwin/laravel-sms library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

banulakwin / laravel-sms example snippets


use Banulakwin\Sms\DTOs\SendSmsRequest;

// Send to a single recipient (uses default driver)
$response = sms()->send(new SendSmsRequest(
    recipients: ['94712345678'],
    message: 'Your OTP is 1234',
));

// Send to multiple recipients
$response = sms()->send(new SendSmsRequest(
    recipients: ['94712345678', '94771234567', '94701234567'],
    message: 'Bulk notification message',
));

// Override sender ID per-request
$response = sms()->send(new SendSmsRequest(
    recipients: ['94712345678'],
    message: 'Hello!',
    senderId: 'CustomName',
));

$response = sms()->schedule(
    new SendSmsRequest(
        recipients: ['94712345678'],
        message: 'Happy Birthday!',
    ),
    scheduleTime: '2025-12-25 10:00',
);

$response = sms()->driver('textlk')->send(new SendSmsRequest(
    recipients: ['94712345678'],
    message: 'Hello via TextLK!',
));

if ($response->success) {
    echo "Sent! Cost: {$response->cost}";
    echo "Status: {$response->status->value}"; // 'sent', 'scheduled', 'failed'
} else {
    echo "Failed: {$response->message}";
}

// Access raw provider response
$rawData = $response->raw;

src/
  SmsServiceProvider.php
  helpers.php
  Contracts/
    SmsProviderInterface.php
  DTOs/
    SendSmsRequest.php
    SendSmsResponse.php
  Enums/
    SmsProvider.php
    SmsStatus.php
  Exceptions/
    SmsException.php
  Managers/
    SmsManager.php
  Providers/
    TextLk/
      TextLkSmsProvider.php
config/
  sms.php