qsms / qbiez-sms
Laravel package for Qbiez SMS API integration - Phone number formatting, queue support, and real-time delivery reports
Installs: 36
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
pkg:composer/qsms/qbiez-sms
Requires
- php: ^8.1
- ext-json: *
- guzzlehttp/guzzle: ^7.0
- illuminate/console: ^9.0|^10.0|^11.0|^12.0
- illuminate/support: ^9.0|^10.0|^11.0|^12.0
- laravel/framework: ^9.0|^10.0|^11.0|^12.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.8
- laravel/pint: ^1.0
- mockery/mockery: ^1.5
- orchestra/testbench: ^7.0|^8.0
- phpunit/phpunit: ^9.5
README
A modern SMS integration package for Laravel applications with comprehensive features and robust error handling.
๐ Requirements
- PHP 8.0+
- Laravel 9.x/10.x/12.x
- Composer
- Active Qbiez SMS account
๐ Quick Start
Registration
First, register for a free account at https://sms.qbiez.com/register to obtain your API token and sender ID.
Installation Steps
- Install the package via Composer:
composer require qsms/qbiez-sms
- Add the following variables to your
.envfile:
QSMS_API_TOKEN=your_api_token_here QSMS_SENDER_ID=your_sender_id_here QSMS_API_URL=https://sms.qbiez.com/api/http/sms/send QSMS_LOGGING_ENABLED=true QSMS_DEFAULT_COUNTRY_CODE=255 QSMS_LOG_FORMAT=json QSMS_LOG_RETENTION=14 QSMS_RATE_LIMIT=30 QSMS_RATE_WINDOW=60
Basic Usage
use Qsms\QbiezSms\SendSMS; $sms = new SendSMS(); $response = $sms->send('255755270046', 'Hello World!');
โ๏ธ Advanced Configuration
To use advanced configuration options, follow these steps:
- Create a new file
config/qsms.phpin your Laravel project - Copy the following configuration:
return [ 'api_token' => env('QSMS_API_TOKEN', ''), 'sender_id' => env('QSMS_SENDER_ID', ''), 'api_url' => env('QSMS_API_URL', 'https://sms.qbiez.com/api/http/sms/send'), 'http' => [ 'timeout' => env('QSMS_HTTP_TIMEOUT', 30), 'retry' => [ 'times' => env('QSMS_RETRY_TIMES', 3), 'sleep' => env('QSMS_RETRY_SLEEP', 100), ], ], 'default_country_code' => env('QSMS_DEFAULT_COUNTRY_CODE', '255'), 'logging' => [ 'enabled' => env('QSMS_LOGGING_ENABLED', true), 'path' => storage_path('logs/qsms'), 'level' => env('QSMS_LOG_LEVEL', 'info'), ], ];
- Optionally, publish the configuration file (if you want to customize it further):
php artisan vendor:publish --tag=qsms-config
๐ฑ Features
- Automatic phone number formatting
- Rate limiting protection
- Comprehensive logging
- Error handling
- Message splitting
- Queue support
Phone Number Formats
// All supported formats: $sms->send('255712345678', 'Message'); // International $sms->send('0712345678', 'Message'); // Local with zero $sms->send('712345678', 'Message'); // Local without zero $sms->send('+255712345678', 'Message'); // With plus
Response Handling
$response = $sms->send('255712345678', 'Test'); if ($response['status'] === 'success') { echo "Message sent! ID: " . $response['data']['message_id']; } else { echo "Error: " . $response['message']; }
๐งช Testing
// tests/Feature/SmsTest.php public function test_can_send_sms() { $sms = new SendSMS(); $response = $sms->send('255712345678', 'Test'); $this->assertEquals('success', $response['status']); }
๐ Logging
Logs are stored in storage/logs/qsms/qsms-YYYY-MM-DD.log
{
"timestamp": "2025-04-27 10:30:00",
"level": "info",
"message": "SMS sent",
"context": {
"recipient": "255712345678",
"status": "delivered"
}
}
๐ Security
- Rate limiting: 10 messages/minute by default
- Secure API token handling
- Phone number validation
- Input sanitization
๐ค Support
๐ License
MIT License. See LICENSE for details.
๐ Changelog
See CHANGELOG.md for release history.