PHP code example of andrejro2 / yeastar-gsm-laravel
1. Go to this page and download the library: Download andrejro2/yeastar-gsm-laravel 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/ */
andrejro2 / yeastar-gsm-laravel example snippets
use AndrejRo2\LaravelYeastarSms\Facades\YeastarSms;
use AndrejRo2\LaravelYeastarSms\Exceptions\YeastarSmsException;
try {
// Send SMS (connection configured via config/env)
$success = YeastarSms::sendSms(
port: 0, // GSM port (0-based)
destination: '+1234567890', // Phone number with country code
message: 'Hello from Laravel!', // Message content
id: 'SMS001' // Optional SMS ID for tracking
);
if ($success) {
echo 'SMS sent successfully!';
}
} catch (YeastarSmsException $e) {
echo 'Error: ' . $e->getMessage();
}