1. Go to this page and download the library: Download kwtsms/laravel-kwtsms 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/ */
kwtsms / laravel-kwtsms example snippets
use KwtSMS\Laravel\Channels\KwtSmsChannel;
use KwtSMS\Laravel\Notifications\KwtSmsMessage;
class OrderShipped extends Notification
{
public function via($notifiable): array
{
return [KwtSmsChannel::class];
}
public function toKwtSms($notifiable): KwtSmsMessage
{
return KwtSmsMessage::create()
->content("Your order has been shipped. Track: {$this->trackingCode}");
}
}
public function routeNotificationForKwtSms(): string
{
return $this->phone; // e.g. "96598765432" (international format, digits only)
}
$user->notify(new OrderShipped($order));
use KwtSMS\Laravel\Services\SmsSender;
$sender = app(SmsSender::class);
// Single recipient
$result = $sender->send('96598765432', 'Hello from kwtSMS!');
// Multiple recipients (batched automatically)
$result = $sender->send(['96598765432', '96512345678'], 'Bulk message');
// With event type (used for template lookup and logging)
$result = $sender->send('96598765432', 'Your OTP is: 123456', null, [
'event_type' => 'otp',
]);
// Success
['success' => true, 'message_id' => 'abc123...', 'numbers_sent' => 1, 'points_charged' => 1, 'balance_after' => 150]
// Failure
['success' => false, 'reason' => 'ERR003', 'error_description' => 'Authentication error...']
// Blocked by guards
['success' => false, 'reason' => 'disabled'] // KWTSMS_ENABLED=false
['success' => false, 'reason' => 'rate_limited'] // per-IP or per-phone limit exceeded
['success' => false, 'reason' => 'no_balance'] // cached balance is zero
['success' => false, 'reason' => 'no_valid_recipients'] // empty list or all out of coverage
use KwtSMS\Laravel\Facades\KwtSms;
KwtSms::send('96598765432', 'Hello!');
KwtSms::balance();
KwtSms::senderids();
$template->render([
'app_name' => 'MyApp',
'otp_code' => '123456',
'expiry_minutes' => '5',
]);
// Output: Your OTP for MyApp is: 123456. Valid for 5 minutes. Do not share this code.
bash
# Sync balance, sender IDs, and coverage from the kwtSMS API
php artisan kwtsms:sync
# Force sync even if recently synced
php artisan kwtsms:sync --force
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.