teaminfinitydev/laravel-sms-notify
最新稳定版本:1.0.2
Composer 安装命令:
composer require teaminfinitydev/laravel-sms-notify
包简介
Laravel Notify.lk SMS Gateway Integration
README 文档
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.
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-07-01