PHP code example of renderbit / laravel-sms

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

    

renderbit / laravel-sms example snippets


return return [
    'url' => env('SMS_API_URL', '<default-preconfigured-url>'),
    'query_params' => [
        'user' => env('SMS_USER'),
        'password' => env('SMS_PASSWORD'),
        'senderid' => env('SMS_SENDER_ID', 'IEMUEM'),
        'channel' => 'trans',
        'DCS' => 0,
        'flashsms' => 0,
        'route' => '1'
    ],
    'number_field' => env('SMS_NUMBER_FIELD', 'number'),
    'message_field' => env('SMS_MESSAGE_FIELD', 'text'),
];;

use Sms;

Sms::send('+919999999999', 'Hello, your OTP is 123456');

use Renderbit\Sms\SmsClient;

class NotificationService
{
    public function __construct(protected SmsClient $sms) {}

    public function notify($phone, $message)
    {
        $this->sms->send($phone, $message);
    }
}

$success = Sms::send($phoneNumber, $message);

if (!$success) {
    // Log failure or retry
}

Sms::shouldReceive('send')
    ->once()
    ->with('+919999999999', 'Test message')
    ->andReturn(true);
bash
php artisan vendor:publish --tag=sms-config