Barta is a clean, expressive Laravel package designed to integrate popular Bangladeshi SMS gateways seamlessly. Whether you're sending OTPs, marketing alerts, or notifications, Barta makes the process as simple as a conversation.
- Multiple Gateways — Seamlessly switch between SMS providers
- Bulk SMS — Send to multiple recipients in a single call
- Queue Support — Dispatch SMS to background jobs
- Laravel Notifications — Native integration with Laravel's notification system
- BD Phone Formatting — Automatic phone number normalization to
8801XXXXXXXXXformat - Extensible — Create custom drivers for any SMS gateway
Install via Composer:
composer require larament/barta
Optionally, you can run the install command:
php artisan barta:install
Set your default driver and add credentials to .env:
BARTA_DRIVER=log
Each gateway requires different credentials. See Gateways for all available options and environment variable names.
Tip
Use log driver during development to avoid sending real SMS.
use Larament\Barta\Facades\Barta; // Send SMS Barta::to('01712345678') ->message('Your OTP is 1234') ->send(); // Use a specific gateway Barta::driver('esms') ->to('01712345678') ->message('Hello!') ->send(); // Bulk SMS Barta::to(['01712345678', '01812345678']) ->message('Hello everyone!') ->send(); // Queue for background processing Barta::to('01712345678') ->message('Queued message') ->queue();
use Larament\Barta\Notifications\BartaMessage; class OrderShipped extends Notification { public function via($notifiable): array { return ['barta']; } public function toBarta($notifiable): BartaMessage { return new BartaMessage("Your order has been shipped!"); } }
Add the route to your model:
public function routeNotificationForBarta($notification): string { return $this->phone; }
Barta automatically normalizes Bangladeshi phone numbers to 8801XXXXXXXXX format:
| Input | Output |
|---|---|
01712345678 |
8801712345678 |
+8801712345678 |
8801712345678 |
composer test # Run tests composer test-coverage # With coverage composer analyse # Static analysis
Use the log driver during testing to avoid sending real SMS.
For complete documentation including custom drivers, error handling, and all gateway configurations:
See CHANGELOG.md for recent changes.
See CONTRIBUTING.md for details.
Report vulnerabilities via our security policy.
MIT License. See LICENSE.md.
Made with ❤️ for the Bangladeshi Laravel Community