The unified interface for every Bangladeshi SMS gateway.
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
| Gateway | Driver | Status |
|---|---|---|
| Log (Development) | log |
✅ Built-in |
| eSMS | esms |
✅ Supported |
| MimSMS | mimsms |
✅ Supported |
| SSL Wireless | ssl |
✅ Supported |
| Grameenphone | grameenphone |
✅ Supported |
| Banglalink | banglalink |
✅ Supported |
| Robi | robi |
✅ Supported |
| Infobip | infobip |
✅ Supported |
| ADN SMS | adnsms |
✅ Supported |
| Alpha SMS | alphasms |
✅ Supported |
| GreenWeb | greenweb |
✅ Supported |
| BulkSMS BD | bulksms |
✅ Supported |
| ElitBuzz | elitbuzz |
✅ Supported |
| SMS NOC | smsnoc |
✅ Supported |
Want more gateways? Request a gateway or contribute a driver.
Install via Composer:
composer require larament/bartaRun the install command (publishes config + optional setup):
php artisan barta:installSet your default driver and add credentials to .env:
BARTA_DRIVER=ssl
# Example: SSL Wireless
BARTA_SSL_TOKEN=your-api-token
BARTA_SSL_SENDER_ID=your-sender-idEach gateway requires different credentials. See config/barta.php for all available options and environment variable names.
💡 Tip: Use
logdriver during development to avoid sending real SMS.
use Larament\Barta\Facades\Barta;
// Send SMS using the default driver
Barta::to('01712345678')
->message('Your OTP is 1234')
->send();// Use a specific gateway
Barta::driver('esms')
->to('01712345678')
->message('Hello from eSMS!')
->send();Send to multiple recipients in a single API call:
Barta::to(['01712345678', '01812345678', '01912345678'])
->message('Hello everyone!')
->send();$response = Barta::to('01712345678')
->message('Hello!')
->send();
// Check if successful
if ($response->success) {
// Access raw API response
$data = $response->data;
}
// Convert to array
$array = $response->toArray();
// ['success' => true, 'data' => [...], 'errors' => []]Dispatch SMS to your queue for background processing:
// Queue with default settings
Barta::to('01712345678')
->message('This will be queued')
->queue();
// Specify queue name
Barta::to('01712345678')
->message('Priority message')
->queue('sms');
// Specify connection and queue
Barta::to('01712345678')
->message('Redis queue')
->queue('sms', 'redis');
// Bulk queued SMS
Barta::to(['01712345678', '01812345678'])
->message('Queued bulk message')
->queue();Barta integrates seamlessly with Laravel's notification system.
use Illuminate\Notifications\Notification;
use Larament\Barta\Notifications\BartaMessage;
class OrderShipped extends Notification
{
public function via($notifiable): array
{
return ['barta'];
}
public function toBarta($notifiable): BartaMessage
{
return new BartaMessage(
"Hi {$notifiable->name}, your order has been shipped!"
);
}
}// app/Models/User.php
public function routeNotificationForBarta($notification): string
{
return $this->phone;
}$user->notify(new OrderShipped());Override the default driver per notification:
class OrderShipped extends Notification
{
public function toBarta($notifiable): BartaMessage
{
return new BartaMessage('Your order shipped!');
}
// Optional: specify driver for this notification
public function bartaDriver(): string
{
return 'mimsms';
}
}Extend Barta to support any SMS gateway.
namespace App\Sms\Drivers;
use Illuminate\Support\Facades\Http;
use Larament\Barta\Drivers\AbstractDriver;
use Larament\Barta\Data\ResponseData;
use Larament\Barta\Exceptions\BartaException;
class CustomGatewayDriver extends AbstractDriver
{
public function send(): ResponseData
{
$this->validate();
$response = Http::withToken($this->config['api_token'])
->post('https://api.customgateway.com/sms', [
'to' => implode(',', $this->recipients),
'message' => $this->message,
'sender' => $this->config['sender_id'],
])
->json();
if ($response['status'] !== 'success') {
throw new BartaException($response['error']);
}
return new ResponseData(
success: true,
data: $response,
);
}
}// app/Providers/AppServiceProvider.php
use App\Sms\Drivers\CustomGatewayDriver;
use Larament\Barta\Facades\Barta;
public function boot(): void
{
Barta::extend('custom', function ($app) {
return new CustomGatewayDriver(config('barta.drivers.custom'));
});
}// config/barta.php
'drivers' => [
// ...existing drivers...
'custom' => [
'api_token' => env('CUSTOM_SMS_TOKEN'),
'sender_id' => env('CUSTOM_SMS_SENDER_ID'),
],
],Barta::driver('custom')
->to('01712345678')
->message('Hello from custom gateway!')
->send();Barta automatically normalizes Bangladeshi phone numbers to the 8801XXXXXXXXX format:
| Input | Output |
|---|---|
1712345678 |
8801712345678 |
01712345678 |
8801712345678 |
8801712345678 |
8801712345678 |
+8801712345678 |
8801712345678 |
017-1234-5678 |
8801712345678 |
Invalid numbers will throw a BartaException.
# Run tests
composer test
# Run tests with coverage
composer test-coverage
# Run static analysis
composer analyseUse the log driver during testing to avoid sending real SMS:
// phpunit.xml or .env.testing
BARTA_DEFAULT_DRIVER=logPlease see CHANGELOG.md for more information on what has changed recently.
Please see CONTRIBUTING.md for details.
Please see our security policy for details on how to report security vulnerabilities.
The MIT License (MIT). Please see LICENSE.md for more information.
Made with ❤️ for the Bangladeshi Laravel Community