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

This package is auto-updated.

Last update: 2026-02-23 06:49:13 UTC


README

Barta Banner

Latest Version on Packagist Total Downloads Run Tests PHPStan Pint License

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