larament / barta
Barta is a Laravel package designed to integrate popular Bangladeshi SMS gateways seamlessly.
Fund package maintenance!
iRaziul
Installs: 20
Dependents: 0
Suggesters: 0
Security: 0
Stars: 55
Watchers: 2
Forks: 6
Open Issues: 0
pkg:composer/larament/barta
Requires
- php: ^8.2
- illuminate/contracts: ^11.0||^12.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^10.0.0||^9.0.0
- pestphp/pest: ^3.0||^4.0
- pestphp/pest-plugin-arch: ^3.0||^4.0
- pestphp/pest-plugin-laravel: ^3.0||^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
README
Introduction
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.
Key Features
- 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
Installation
Install via Composer:
composer require larament/barta
Optionally, you can run the install command:
php artisan barta:install
Configuration
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.
Usage
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();
Laravel Notifications
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; }
Phone Number Formatting
Barta automatically normalizes Bangladeshi phone numbers to 8801XXXXXXXXX format:
| Input | Output |
|---|---|
01712345678 |
8801712345678 |
+8801712345678 |
8801712345678 |
Testing
composer test # Run tests composer test-coverage # With coverage composer analyse # Static analysis
Use the log driver during testing to avoid sending real SMS.
Documentation
For complete documentation including custom drivers, error handling, and all gateway configurations:
Changelog
See CHANGELOG.md for recent changes.
Contributing
See CONTRIBUTING.md for details.
Security
Report vulnerabilities via our security policy.
Credits
License
MIT License. See LICENSE.md.
Made with ❤️ for the Bangladeshi Laravel Community