Skip to content
/ barta Public

Barta is a Laravel package designed to integrate popular Bangladeshi SMS gateways seamlessly.

License

Notifications You must be signed in to change notification settings

iRaziul/barta

Repository files navigation

Barta (কথা) - The unified interface for every Bangladeshi SMS gateway.


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 8801XXXXXXXXX format
  • 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();

📚 Full Usage Guide →


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;
}

📚 Full Notifications Guide →


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:

📚 barta.larament.com


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

⭐ Star us on GitHub

About

Barta is a Laravel package designed to integrate popular Bangladeshi SMS gateways seamlessly.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Contributors 3

  •  
  •  
  •  

Languages