PHP code example of offline-agency / laravel-aruba-sms

1. Go to this page and download the library: Download offline-agency/laravel-aruba-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/ */

    

offline-agency / laravel-aruba-sms example snippets


use Illuminate\Notifications\Notification;
use OfflineAgency\ArubaSms\ArubaSmsMessage;

class OrderShippedNotification extends Notification
{
    public function via($notifiable): array
    {
        return ['aruba-sms'];
    }

    public function toArubaSms($notifiable): ArubaSmsMessage
    {
        return (new ArubaSmsMessage())
            ->content("Your order #{$this->order->id} has been shipped")
            ->to($notifiable->phone_number);
    }
}

use OfflineAgency\ArubaSms\Notifications\SendSmsNotification;
use Illuminate\Support\Facades\Notification;

// Send to an on-demand notifiable (no User model needed)
Notification::route('aruba-sms', null)
    ->notify(new SendSmsNotification('Your message', '+393331234567'));

// Or send via a notifiable model
$user->notify(new SendSmsNotification('Your message', '+393331234567'));

use OfflineAgency\ArubaSms\ArubaSmsClient;
use OfflineAgency\ArubaSms\ArubaSmsMessage;

$client = app(ArubaSmsClient::class);
$message = new ArubaSmsMessage('Hello!', '+393331234567');
$response = $client->sendMessage($message);

use OfflineAgency\ArubaSms\Facades\ArubaSms;
use OfflineAgency\ArubaSms\ArubaSmsMessage;

// Send a message
$message = new ArubaSmsMessage('Hello!', '+393331234567');
ArubaSms::sendMessage($message);

// Check remaining credits
$response = ArubaSms::checkSmsStatus();

// Get sending history
$response = ArubaSms::getSmsHistory('20260101000001');

class LegacyNotification extends Notification
{
    public string $message = 'Hello';
    public string $recipient = '+393331234567';
    public string $message_type = 'N';

    public function via($notifiable): array
    {
        return ['aruba-sms'];
    }
}

use OfflineAgency\ArubaSms\Support\PhoneNumberFormatter;

// Add +39 prefix and strip spaces
PhoneNumberFormatter::format('333 123 4567');    // '+393331234567'
PhoneNumberFormatter::format('+393331234567');   // '+393331234567' (unchanged)
PhoneNumberFormatter::format('+447911123456');   // '+447911123456' (non-IT preserved)

// Strip spaces only
PhoneNumberFormatter::stripSpaces('+39 333 123 4567'); // '+393331234567'
bash
php artisan vendor:publish --tag=aruba-sms-config
bash
php artisan aruba:check-remaining-sms

[2026-02-19 10:30:00] local.INFO: *** Aruba SMS DEBUG ***
[2026-02-19 10:30:00] local.INFO: Notification sent successfully!
[2026-02-19 10:30:00] local.INFO: Recipient: +393331234567
[2026-02-19 10:30:00] local.INFO: Message: Your code is 123456
[2026-02-19 10:30:00] local.INFO: Message Type: N
[2026-02-19 10:30:00] local.INFO: *** *** ***