Laravel package for Notify.lk SMS Gateway Integration
- PHP 8.1, 8.2, or 8.3
- Laravel 9.x, 10.x, 11.x, or 12.x
You can install the package via composer:
composer require teaminfinitydev/laravel-sms-notify
- 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
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
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 | 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 |
- 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
-
"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
composer test
The MIT License (MIT). Please see License File for more information.