Download the PHP package kaydee123/msg91-laravel without Composer
On this page you can find all versions of the php package kaydee123/msg91-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package msg91-laravel
MSG91 Laravel Package
Laravel integration for MSG91 SMS and OTP services. This package provides a seamless Laravel integration for the kaydee123/msg91-php package.
Features
- Send SMS messages (single and bulk)
- Send OTP via SMS
- Verify OTP codes
- Retry/Resend OTP (text or voice)
- Template-based SMS support
- DLT compliance support for India
- Comprehensive error handling
- Laravel Service Provider with auto-discovery
- Facade support for easy access
- Helper functions
- Publishable configuration file
Requirements
- PHP 8.0 to 8.5
- Laravel 8.x, 9.x, 10.x, 11.x, or 12.x
- Composer
- MSG91 account with API credentials
Installation
Install the package via Composer:
The package will automatically register itself using Laravel's auto-discovery feature.
Configuration
Publish Configuration File
Publish the configuration file to customize settings:
This will create a config/msg91.php file in your Laravel application.
Environment Variables
Add your MSG91 Auth Key to your .env file:
You can get your MSG91 Auth Key from your MSG91 Dashboard.
Usage
Using the Facade
The package provides a Msg91 facade for easy access:
Using Dependency Injection
You can inject the Msg91Client directly into your controllers or services:
Using Helper Function
You can also use the msg91() helper function:
Using the Service Container
You can resolve the client from the service container:
Examples
SMS Examples
Send SMS using Template (Recommended):
Send SMS to Multiple Recipients:
Send DLT SMS (Promotional):
Send DLT SMS (Transactional):
OTP Examples
Send OTP (Template ID required for India):
Send OTP with Custom Options:
Verify OTP:
Retry/Resend OTP:
DLT Compliance for India
DLT (Distributed Ledger Technology) is mandatory for sending commercial SMS in India. TRAI requires all SMS messages to be DLT-compliant.
For Indian mobile numbers (country code 91), a Template ID is mandatory when sending OTP due to DLT compliance requirements. The package will automatically validate this requirement.
Error Handling
The package provides custom exception classes for better error handling:
Configuration Options
The configuration file (config/msg91.php) supports the following options:
auth_key- Your MSG91 authentication key (required)base_url- Base URL for MSG91 API (default:https://control.msg91.com/api/)timeout- Request timeout in seconds (default:30)debug- Enable debug logging (default:false)
API Reference
For complete API documentation, refer to the base package documentation: kaydee123/msg91-php
SMSBuilder Methods
template($templateId)- Set template ID for template-based SMS (required)numbers($mobiles)- Set recipient mobile number(s) - string or arrayto($mobile)- Set recipient mobile number(s) - string or arrayvariables(array $variables)- Set multiple template variables (optional)variable($key, $value)- Set a single template variable (optional)recipients(array $recipients)- Set recipients with individual variablespromotional()- Set route to promotional (route 1)transactional()- Set route to transactional (route 4, default)sender_id($id)- Set sender ID (required for DLT SMS)mobiles($mobiles)- Set mobiles for DLT SMSdlt_template_id($id)- Set DLT Template ID (India only)message($message)- Set SMS message content (required for DLT SMS)send()- Send the SMS
OTPBuilder Methods
template($templateId)- Set template ID (required)number($mobile)- Set mobile numberto($mobile)- Set mobile numberlength($digits)- Set OTP length/digits (optional, default: 4)expiry($minutes)- Set OTP expiry in minutes (optional, default: 1)viaText()- Set retry type to textviaVoice()- Set retry type to voicesend()- Send OTPverify($otp)- Verify OTP coderetry()- Retry/resend OTPresend()- Resend OTP (text by default)
Laravel Version Compatibility
This package is tested and compatible with:
- Laravel 8.x
- Laravel 9.x
- Laravel 10.x
- Laravel 11.x
- Laravel 12.x
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This package is open-sourced software licensed under the MIT license.
Support
For MSG91 API documentation, visit https://docs.msg91.com/
For issues related to this package, please open an issue on GitHub.
Related Packages
- kaydee123/msg91-php - The base PHP package (framework-agnostic)
All versions of msg91-laravel with dependencies
kaydee123/msg91-php Version ^1.0
illuminate/support Version ^8.0|^9.0|^10.0|^11.0|^12.0