teaminfinitydev / laravel-sms-notify
Laravel Notify.lk SMS Gateway Integration
Fund package maintenance!
teaminfinitydev
Buy Me A Coffee
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 9
Watchers: 3
Forks: 1
Open Issues: 0
pkg:composer/teaminfinitydev/laravel-sms-notify
Requires
- php: ^8.1|^8.2|^8.3
- guzzlehttp/guzzle: ^7.0
- illuminate/support: ^9.0|^10.0|^11.0|^12.0
Requires (Dev)
- orchestra/testbench: ^7.0|^8.0|^9.0|^10.0
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^9.0|^10.0|^11.0
README
Laravel package for Notify.lk SMS Gateway Integration
Requirements
- PHP 8.1, 8.2, or 8.3
- Laravel 9.x, 10.x, 11.x, or 12.x
Installation
You can install the package via composer:
composer require teaminfinitydev/laravel-sms-notify
Configuration
- Publish the configuration file:
php artisan vendor:publish --provider="TeamInfinityDev\SmsNotify\SmsNotifyServiceProvider"
- Add the following variables to your .env file:
# Required Configuration NOTIFI_USER_ID=your-user-id NOTIFI_API_KEY=your-api-key NOTIFI_SENDER_ID=your-sender-id # Optional Configuration NOTIFI_API_URL=https://app.notify.lk/api/v1 NOTIFI_TIMEOUT=30 NOTIFI_CONNECT_TIMEOUT=10 NOTIFI_SSL_VERIFY=true NOTIFI_RETRY_ATTEMPTS=3 NOTIFI_RETRY_DELAY=1 # Development/Testing Configuration NOTIFI_MOCK_RESPONSES=false NOTIFI_LOG_REQUESTS=false
For Local Development
If you're having SSL or connection issues in local development, add these to your .env
:
# Disable SSL verification for local development NOTIFI_SSL_VERIFY=false # Enable request logging for debugging NOTIFI_LOG_REQUESTS=true # Use mock responses for testing without API calls NOTIFI_MOCK_RESPONSES=true
Usage
use TeamInfinityDev\SmsNotify\Services\NotifyService; $notifyService = new NotifyService(); // Send to single number $response = $notifyService->send('771234567', 'Your message here'); // Send to multiple numbers $response = $notifyService->send(['771234567', '772345678'], 'Your message here'); // Response format [ 'success' => true, 'data' => [ 'message_id' => 'xxx', 'status' => 'queued' ], 'status_code' => 200 ]
Laravel Version Compatibility
Laravel Version | Package Version | PHP Version Required |
---|---|---|
9.x | ^1.1 | ^8.1, ^8.2, ^8.3 |
10.x | ^1.1 | ^8.1, ^8.2, ^8.3 |
11.x | ^1.1 | ^8.2, ^8.3 |
12.x | ^1.1 | ^8.2, ^8.3 |
Features
- Send SMS to single or multiple numbers
- Automatic phone number formatting
- Configurable retry attempts
- Exception handling
- Comprehensive testing
- Support for Laravel 9, 10, 11, and 12
- SSL verification control for local development
- Request logging for debugging
- Mock responses for testing
- Connection timeout and retry configuration
- Detailed error handling for network issues
Troubleshooting
Common Issues
-
"Could not resolve host" error in local development:
NOTIFI_SSL_VERIFY=false
-
Connection timeout issues:
NOTIFI_TIMEOUT=60 NOTIFI_CONNECT_TIMEOUT=30
-
Enable debugging:
NOTIFI_LOG_REQUESTS=true
-
Test without real API calls:
NOTIFI_MOCK_RESPONSES=true
Testing
composer test
License
The MIT License (MIT). Please see License File for more information.