1. Go to this page and download the library: Download calisero/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/ */
calisero / laravel-sms example snippets
use Calisero\LaravelSms\Facades\Calisero;
$response = Calisero::sendSms([
'to' => '+40712345678',
'text' => 'Hello from Laravel!',
// 'from' => 'MyBrand' // Include ONLY if approved by Calisero
]);
use Calisero\LaravelSms\Facades\Calisero;
// Send a verification code (with brand)
$response = Calisero::sendVerification([
'to' => '+40712345678',
'brand' => 'MyApp', // Required if no template
'expires_in' => 5, // Optional: 1-10 minutes, default 5
]);
// OR send with custom template
$response = Calisero::sendVerification([
'to' => '+40712345678',
'template' => 'Your verification code is {code}. Valid for 5 minutes.',
'expires_in' => 5,
]);
// The response
use Calisero\LaravelSms\Notification\SmsMessage;
use Illuminate\Notifications\Notification;
class WelcomeNotification extends Notification
{
public function via($notifiable): array
{
return ['calisero'];
}
public function toCalisero($notifiable): SmsMessage
{
return SmsMessage::create('Welcome to our app!')
// ->from('MyBrand') // Uncomment only after approval
;
}
}
use App\Models\User;
use App\Notifications\WelcomeNotification;
$user = User::find(1);
$user->notify(new WelcomeNotification());
public function routeNotificationForCalisero($notification): string
{
return $this->phone; // Return the user's phone number
}
use Calisero\LaravelSms\Contracts\SmsClient;
class SmsService
{
public function __construct(private SmsClient $client) {}
public function sendWelcomeSms(string $phone): void
{
$this->client->sendSms([
'to' => $phone,
'text' => 'Welcome to our service!',
'from' => 'MyApp',
'idempotencyKey' => 'welcome-' . uniqid(),
]);
}
}
use Calisero\LaravelSms\Validation\Rule;
use Illuminate\Foundation\Http\FormRequest;
class SendSmsRequest extends FormRequest
{
public function rules(): array
{
return [
'phone' => ['