moffhub / sms-handler
A simple sms integration helper
Requires
- php: ^8.3
- laravel/framework: ^11.0
Requires (Dev)
- laravel/pint: ^1.17
- orchestra/testbench: v9.4.0
- phpunit/phpunit: ^11.0
README
This library is used to send interface with the SMS API. It is used to send SMS messages to users.
Features
- Send SMS
- Send Scheduled SMS
- Send Bulk SMS
- Send Bulk Scheduled SMS
- Get Message Info
- Log SMS messages in the database
- Get SMS messages from the database
Providers
- Add Advanta sms provider
- Add Africas Talking sms provider
- Add Twilio sms provider
- Add Nexmo sms provider
- Add Custom sms provider
Installation
You can install the package via composer:
SMS_PROVIDER=advanta // or africastalking, onfonmedia ADVANTA_API_KEY= ADVANTA_API_URL= ADVANTA_API_URL= ADVANTA_PARTNER_ID= ADVANTA_SHORT_CODE= AT_API_KEY= AT_API_URL= ONFON_API_KEY= ONFON_API_URL= ONFON_SENDER_ID= ONFON_CLIENT_ID= SMS_LOG_CHANNEL=
composer require moffhub/sms-lib
You can publish the config file with:
php artisan vendor:publish --provider="Moffhub\SmsLib\SmsLibServiceProvider" --tag="config"
Configuration
The library provides simple methods you can use
sendSms($to, $message)
This method sends a single SMS to a single recipient
sendBulkSms($to, $message)
This method sends a single SMS to multiple recipients
sendScheduledSms($to, $message, $time)
This method sends a single SMS to a single recipient at a scheduled time
sendBulkScheduledSms($to, $message, $time)
This method sends a single SMS to multiple recipients at a scheduled time
getMessageInfo($messageId)
This method gets the status of a message
The package also logs the messages and their responses in the database. You can view the messages in the database by running the command below
Usage
use Moffhub\SmsLib\SmsLib; $sms = new SmsLib(); $sms->sendSms('0700000000', 'Hello World'); $sms->sendScheduledSms('0700000000', 'Hello World', '2024-12-12 12:00');
or
use Moffhub\SmsLib\SendSms; SendSms::sendSms('0700000000', 'Hello World'); SendSms::sendScheduledSms('0700000000', 'Hello World', '2024-12-12 12:00');