Switching Drivers
Use different gateways for different purposes.
Runtime Selection
Section titled “Runtime Selection”Barta::driver('ssl')->to('01712345678')->message('Via SSL')->send();Barta::driver('esms')->to('01712345678')->message('Via eSMS')->send();Multi-Gateway Architecture
Section titled “Multi-Gateway Architecture”class SmsService{ public function sendOtp(string $phone, string $otp): void { Barta::driver('ssl') ->to($phone) ->message("Your OTP is {$otp}") ->send(); }
public function sendPromotion(array $phones, string $message): void { Barta::driver('bulksms') ->to($phones) ->message($message) ->queue(); }}Fallback Strategy
Section titled “Fallback Strategy”function sendWithFallback(string $phone, string $message): bool{ foreach (['ssl', 'esms', 'mimsms'] as $driver) { try { $response = Barta::driver($driver) ->to($phone)->message($message)->send(); if ($response->success) return true; } catch (BartaException $e) { continue; } } return false;}