chandan07cse / robi-sms
Laravel package for Robi/AdaReach Business SMS API integration
Installs: 37
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/chandan07cse/robi-sms
Requires
- php: ^7.4|^8.0|^8.1|^8.2|^8.3
- ext-curl: *
- ext-json: *
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- orchestra/testbench: ^8.0|^9.0
- phpunit/phpunit: ^10.0
Suggests
- illuminate/http: ^8.0|^9.0|^10.0|^11.0 - Required for Laravel integration
- illuminate/support: ^8.0|^9.0|^10.0|^11.0 - Required for Laravel integration
- predis/predis: ^1.1|^2.0 - Optional for Redis queue support
- symfony/process: ^5.0|^6.0|^7.0 - Optional for background processing
This package is auto-updated.
Last update: 2026-02-04 09:40:15 UTC
README
A comprehensive PHP package for integrating with AdaReach (Robi/MobiReach) Business SMS API. Works seamlessly with Laravel or as a standalone PHP library (PHP 7.4+).
๐ Table of Contents
- Features
- Requirements
- Laravel Installation
- Standalone Installation
- Phone Number Formats
- Bangla/Unicode SMS
- API Reference
- Examples
- Troubleshooting
- Changelog
- License
โจ Features
Core Features
- โ Send single and bulk SMS messages
- โ Phone auto-normalization (01XXX โ 880XXX, +880XXX โ 880XXX)
- โ Bangla/Unicode auto-detection
- โ Real-time SMS delivery tracking
- โ Balance checking (API & GUI balance)
- โ PHP 7.4+ compatible
- โ Works without Laravel (Standalone mode)
- โ Token-based authentication with auto-refresh
- โ File-based token caching
Dashboard Features
- ๐จ Modern, responsive UI with tabs
- ๐ Character counter with SMS parts calculation
- ๐ฑ Single & Bulk SMS sending
- ๐ฐ Real-time balance display
- ๐ Credential management
- ๐ Message history (Laravel mode)
- ๐ Analytics and statistics (Laravel mode)
Security
- ๐ Token-based authentication with auto-refresh
- ๐ Encrypted credentials (Laravel mode)
- ๐พ File-based token caching (Standalone mode)
- ๐ก๏ธ Database-backed configuration (Laravel mode)
๐ Requirements
Laravel Requirements
- PHP 8.1 or higher
- Laravel 10.x or 11.x
- MySQL/PostgreSQL database
- Redis (optional, for caching)
- Node.js 16+ (for dashboard assets)
Standalone Requirements
- PHP 7.4 or higher (PHP 7.4, 8.0, 8.1, 8.2, 8.3)
- cURL extension
- JSON extension
- Composer
๐ฏ Laravel Installation
Perfect for Laravel applications with full dashboard, analytics, and database integration.
Step 1: Install Package
composer require chandan07cse/robi-sms
Step 2: Publish Configuration & Assets
# Publish config, migrations, and assets php artisan vendor:publish --provider="AdaReach\Sms\AdaReachServiceProvider" # Run migrations php artisan migrate # Build dashboard assets (optional) npm install && npm run build
Step 3: Configure Environment
Add these to your .env file:
ADAREARCH_USERNAME=your_username ADAREARCH_PASSWORD=your_password ADAREARCH_BASE_URL=https://api.mobireach.com.bd ADAREARCH_DEFAULT_SENDER=8801XXXXXXXXX
Step 4: Usage in Laravel
use AdaReach\Sms\Facades\AdaReach; // Send single SMS $response = AdaReach::sendSms('01703611094', 'Hello from Laravel!'); // Send bulk SMS $response = AdaReach::sendBulkSms( ['01703611094', '01812345678'], 'Bulk message' ); // Check balance $balance = AdaReach::getBalance(); // Get account info $info = AdaReach::getAccountInfo();
Step 5: Access Dashboard
Visit your Laravel SMS dashboard:
http://your-laravel-app.test/adarearch/dashboard
Dashboard Features:
- ๐ Real-time analytics & statistics
- ๐ฑ Send single & bulk SMS
- ๐ฐ Balance monitoring
- ๐ Message history & tracking
- ๐ Credential management
- ๐ Export message logs
๐ Standalone Installation (Without Laravel)
Perfect for plain PHP projects, WordPress, custom frameworks, or any PHP 7.4+ application.
Step 1: Install via Composer
composer require chandan07cse/robi-sms
Step 2: Basic Setup
<?php require_once __DIR__ . '/vendor/autoload.php'; use AdaReach\Sms\StandaloneClient; // Initialize client $client = new StandaloneClient( 'your_username', 'your_password', 'YourSenderID' // Optional but recommended ); // Send SMS try { $response = $client->sendSms('01703611094', 'Hello from PHP!'); if ($response['status'] === 'SUCCESS') { echo "โ SMS sent! Message ID: " . $response['id']; } } catch (Exception $e) { echo "โ Error: " . $e->getMessage(); }
Send Bulk SMS
$phones = ['01703611094', '01812345678', '01956789012']; $message = 'Hello everyone!'; $response = $client->sendBulkSms($phones, $message); echo "Sent to " . count($response['successful']) . " numbers"; foreach ($response['failed'] as $failed) { echo "Failed: {$failed['phone']} - {$failed['error']}\n"; }
Check Balance
// Get current balance $balance = $client->getBalance(); echo "Current balance: {$balance} BDT\n"; // Get detailed account info $accountInfo = $client->getAccountInfo(); print_r($accountInfo);
Advanced Configuration
$client = new StandaloneClient( 'username', 'password', 'SenderID', 'https://api.mobireach.com.bd', // Custom base URL '/path/to/cache' // Custom cache directory ); // Change sender ID dynamically $client->setSender('NewSenderID'); // Get current sender $currentSender = $client->getSender();
Dashboard Setup (Optional)
Add ONE line to your index.php or routing file:
require __DIR__ . '/vendor/chandan07cse/robi-sms/routes/sms-dashboard.php';
Then visit: http://yoursite.com/sms-dashboard
Alternative Methods:
Using .htaccess (Apache):
RewriteEngine On RewriteRule ^sms-dashboard$ vendor/chandan07cse/robi-sms/public/sms-dashboard.php [L]
Using Nginx:
location /sms-dashboard { rewrite ^/sms-dashboard$ /vendor/chandan07cse/robi-sms/public/sms-dashboard.php last; }
PHP Built-in Server (Development):
cd vendor/chandan07cse/robi-sms/public
php -S localhost:8080 sms-dashboard.php
Environment Configuration:
Create .env file in your project root:
ADAREARCH_USERNAME=your_username ADAREARCH_PASSWORD=your_password ADAREARCH_DEFAULT_SENDER=8801XXXXXXXXX
๐ฑ Phone Number Formats
The package automatically normalizes phone numbers. All these formats work:
// All these are normalized to: 8801703611094 $client->sendSms('01703611094', 'Test'); // โ Auto-adds 880 $client->sendSms('1703611094', 'Test'); // โ Auto-adds 880 $client->sendSms('8801703611094', 'Test'); // โ Works as-is $client->sendSms('+8801703611094', 'Test'); // โ Auto-removes +
How it Works
- Starts with
+880โ Removes+โ8801703611094 - Starts with
880โ No change โ8801703611094 - Starts with
01โ Replaces with880โ8801703611094 - Starts with
1โ Adds880prefix โ8801703611094
๐ง๐ฉ Bangla/Unicode SMS
The package automatically detects Bangla/Unicode characters and sets the correct content type.
Auto-Detection
// English SMS (contentType=1, 160 chars/SMS) $client->sendSms('01703611094', 'Hello World'); // Bangla SMS (contentType=2, 70 chars/SMS) - AUTO-DETECTED $client->sendSms('01703611094', 'เฆนเงเฆฏเฆพเฆฒเง เฆฌเฆพเฆเฆฒเฆพ!'); // Mixed content (Unicode auto-detected) $client->sendSms('01703611094', 'Hello เฆนเงเฆฏเฆพเฆฒเง 123'); // Emoji (Unicode auto-detected) $client->sendSms('01703611094', 'Hello ๐ World ๐');
Character Limits
| Content Type | Characters per SMS | Detection |
|---|---|---|
| English/ASCII | 160 characters | Automatic |
| Bangla/Unicode | 70 characters | Automatic |
| Emoji/Special | 70 characters | Automatic |
Manual Override
// Force Unicode (not recommended, auto-detection is better) $response = $client->sendSms('01703611094', 'Test', null, true);
๐ API Reference
StandaloneClient
Constructor
public function __construct( string $username, string $password, string $sender = null, string $baseUrl = 'https://api.mobireach.com.bd', string $cacheDir = null )
Methods
sendSms()
Send SMS to a single recipient.
public function sendSms( string $phone, string $message, string $sender = null, bool $isUnicode = null ): array
Parameters:
$phone- Phone number (auto-normalized)$message- SMS content$sender- Sender ID (optional, uses default if not provided)$isUnicode- Force Unicode mode (optional, auto-detected if null)
Returns:
[
'status' => 'SUCCESS',
'id' => 'message_id',
'phone' => '8801703611094',
'message' => 'Your message',
'sender' => 'SenderID'
]
sendBulkSms()
Send SMS to multiple recipients.
public function sendBulkSms( array $phones, string $message, string $sender = null, bool $isUnicode = null ): array
Returns:
[
'status' => 'SUCCESS',
'successful' => ['8801703611094', '8801812345678'],
'failed' => [],
'total' => 2
]
getBalance()
Check account balance.
public function getBalance(): float
Returns: Balance amount (float)
getAccountInfo()
Get detailed account information.
public function getAccountInfo(): array
Returns:
[
'balance' => 1000.50,
'username' => 'your_username',
'api_url' => 'https://api.mobireach.com.bd'
]
setSender()
Set or change the sender ID.
public function setSender(string $sender): self
getSender()
Get current sender ID.
public function getSender(): ?string
๐ก Examples
Example 1: Simple SMS Sending
<?php require 'vendor/autoload.php'; use AdaReach\Sms\StandaloneClient; $client = new StandaloneClient('username', 'password', 'MySender'); try { $result = $client->sendSms('01703611094', 'Hello from AdaReach!'); echo "Success! Message ID: " . $result['id']; } catch (Exception $e) { echo "Error: " . $e->getMessage(); }
Example 2: Bulk SMS with Loop
<?php require 'vendor/autoload.php'; use AdaReach\Sms\StandaloneClient; $client = new StandaloneClient('username', 'password', 'MySender'); // Read phones from database or CSV $users = [ ['phone' => '01703611094', 'name' => 'John'], ['phone' => '01812345678', 'name' => 'Jane'], ['phone' => '01956789012', 'name' => 'Bob'] ]; foreach ($users as $user) { $message = "Hello {$user['name']}, Welcome to our service!"; try { $result = $client->sendSms($user['phone'], $message); echo "โ Sent to {$user['name']}: {$result['id']}\n"; } catch (Exception $e) { echo "โ Failed for {$user['name']}: {$e->getMessage()}\n"; } // Rate limiting (optional) sleep(1); }
Example 3: Check Balance Before Sending
<?php require 'vendor/autoload.php'; use AdaReach\Sms\StandaloneClient; $client = new StandaloneClient('username', 'password', 'MySender'); // Check balance first $balance = $client->getBalance(); echo "Current balance: {$balance} BDT\n"; if ($balance < 10) { die("Insufficient balance! Please recharge.\n"); } // Send SMS $result = $client->sendSms('01703611094', 'Your OTP is: 123456'); echo "OTP sent! Message ID: " . $result['id'];
Example 4: Bangla SMS with Error Handling
<?php require 'vendor/autoload.php'; use AdaReach\Sms\StandaloneClient; $client = new StandaloneClient('username', 'password', 'MySender'); $phones = ['01703611094', '01812345678']; $message = 'เฆเฆชเฆจเฆพเฆฐ เฆ เฆฐเงเฆกเฆพเฆฐ เฆธเฆซเฆฒ เฆนเฆฏเฆผเงเฆเงเฅค เฆงเฆจเงเฆฏเฆฌเฆพเฆฆ!'; foreach ($phones as $phone) { try { $result = $client->sendSms($phone, $message); if ($result['status'] === 'SUCCESS') { echo "โ Sent to {$phone}\n"; } else { echo "โ Failed to {$phone}: " . ($result['error'] ?? 'Unknown error') . "\n"; } } catch (Exception $e) { echo "โ Exception for {$phone}: {$e->getMessage()}\n"; } }
Example 5: Using with Database
<?php require 'vendor/autoload.php'; use AdaReach\Sms\StandaloneClient; $client = new StandaloneClient('username', 'password', 'MySender'); // Connect to database $pdo = new PDO('mysql:host=localhost;dbname=mydb', 'user', 'pass'); // Get pending SMS from database $stmt = $pdo->query("SELECT id, phone, message FROM pending_sms WHERE sent = 0 LIMIT 100"); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { try { $result = $client->sendSms($row['phone'], $row['message']); // Update database $update = $pdo->prepare("UPDATE pending_sms SET sent = 1, message_id = ?, sent_at = NOW() WHERE id = ?"); $update->execute([$result['id'], $row['id']]); echo "โ Sent SMS ID: {$row['id']}\n"; } catch (Exception $e) { // Log error $error = $pdo->prepare("UPDATE pending_sms SET error = ? WHERE id = ?"); $error->execute([$e->getMessage(), $row['id']]); echo "โ Failed SMS ID: {$row['id']}\n"; } }
๐ง Troubleshooting
Common Issues
1. Error 1510: "New API Other Error"
Cause: Using old API parameter names.
Solution: Update to latest version:
composer update chandan07cse/robi-sms
2. Phone Number Not Working
Cause: Invalid phone format.
Solution: Use any of these formats (auto-normalized):
'01703611094' // โ Recommended '8801703611094' // โ Also works '+8801703611094' // โ Also works
3. Bangla SMS Not Sending
Cause: Old version without Unicode detection.
Solution: Update to latest version. Unicode is now auto-detected:
composer update chandan07cse/robi-sms
4. Dashboard Not Loading
Cause: Route not registered or .env not configured.
Solution:
- Add route include:
require __DIR__ . '/vendor/chandan07cse/robi-sms/routes/sms-dashboard.php';
- Create
.envfile with credentials
5. Token Cache Issues
Cause: No write permissions on cache directory.
Solution:
# Create cache directory mkdir -p storage/cache/sms # Set permissions chmod -R 755 storage/cache/sms
Debug Mode
Enable debug mode to see detailed API responses:
$client = new StandaloneClient('user', 'pass', 'sender'); try { $result = $client->sendSms('01703611094', 'Test'); print_r($result); // See full response } catch (Exception $e) { echo "Error: " . $e->getMessage(); echo "\nTrace: " . $e->getTraceAsString(); }
๐ Changelog
[v2.1.0] - 2026-01-31
๐ Critical Bug Fix - SMS Sending Now Works!
Fixed Error 1510 - Standalone client was using incorrect API parameter names.
Fixed:
- โ
Corrected AdaReach API parameter names in StandaloneClient
- Changed
recipientsโreceiver(API requirement) - Changed
textโcontent(API requirement) - Added
msgType= 'T' (Transactional/Promotional flag) - Added
requestType= 'S'/'B' (Single/Bulk detection) - Added
contentType= 1/2 (Regular text/Unicode flag)
- Changed
Impact:
- โ SMS sending now works correctly in standalone mode
- โ Fixes Error 1510 "New API Other Error"
- โ No breaking changes - existing code works as-is
[v2.0.0] - 2026-01-31
๐ Major Release - PHP 7.4+ Support & Standalone Mode
Added:
- โ Standalone Client for use without Laravel
- โ PHP 7.4, 8.0, 8.1, 8.2, 8.3 support
- โ Phone number auto-normalization (01XXX โ 880XXX)
- โ Bangla/Unicode auto-detection
- โ Ready-to-use SMS dashboard
- โ File-based token caching
- โ cURL-based HTTP client
๐ License
This package is open-sourced software licensed under the MIT license.
๐ค Support
- GitHub: https://github.com/chandan07cse/robi-sms
- Packagist: https://packagist.org/packages/chandan07cse/robi-sms
- Issues: https://github.com/chandan07cse/robi-sms/issues
๐ Credits
- Author: chandan07cse
- API Provider: AdaReach (MobiReach)
Made with โค๏ธ for the PHP community