shaz3e / twilio
Send SMS with Twilio in your Laravel Application
v1.1.0
2024-12-17 14:02 UTC
Requires
- twilio/sdk: ^8.3
README
Introduction
This is a Laravel package for sending SMS with Twilio
Installation
You can install the package via composer by running the following command in your terminal
composer require shaz3e/twilio
Publishing Configurations
Publish config only
php artisan vendor:publish --tag=twilio-config
This is the content of the config file that will be published at config/twilio.php
<?php
return [
'twilio_sid' => env('TWILIO_ACCOUNT_SID'),
'twilio_token' => env('TWILIO_AUTH_TOKEN'),
'twilio_from' => env('TWILIO_SMS_FROM'),
];
Update .env file
Next, edit your .env file with your Twilio Credentials TWILIO_ACCOUNT_SID=xxxxx TWILIO_AUTH_TOKEN=xxxxx TWILIO_SMS_FROM=+xxxxx
Usage
To send a SMS message, you can use the notify() method available on the Twilio Facade
<?php
use Shaz3e\Twilio\Facades\Twilio;
$sendSms = Twilio::notify('+123456789', 'Hello')
return $sendSms;
To send WhatsAp message you can use the notifyWhatsApp method available on the Twilio Facade
<?php
use Shaz3e\Twilio\Facades\Twilio;
$sendWhatsApp = Twilio::notifyWhatsApp('+123456789', 'Hello')
return $sendWhatsApp;
Contributing
- If you have any suggestions please let me know : https://github.com/Shaz3e/twilio/pulls.
- Please help me improve code https://github.com/Shaz3e/twilio/pulls
License
Twilio is licensed under the MIT license. Enjoy!