masrur447 / twilio-sdk
Laravel integration for Twilio SDK
1.0.0
2025-07-27 07:10 UTC
Requires
- php: ^8.2
- illuminate/support: ^12.0
- twilio/sdk: ^8.7
README
A simple Laravel package that provides an elegant wrapper for sending SMS using the Twilio API.
Developed by Masrur
๐ Features
- Easy Twilio integration in Laravel
- Simple API to send SMS
- Configuration via
.env
file
๐งฑ Requirements
- PHP 8.2 or higher
- Laravel 12x
- Twilio Account & Credentials
๐ฆ Installation
Install the package via Composer:
composer require masrur447/twilio-sdk
โ๏ธ Configuration
Step 1: Publish the config file
php artisan vendor:publish --tag=twilio-config
This will publish the config file to:
config/twilio.php
Step 2: Add your credentials in .env
TWILIO_SID=your_twilio_account_sid TWILIO_TOKEN=your_twilio_auth_token TWILIO_SENDER_NUMBER=your_twilio_whatsapp_sender_number TWILIO_SMS_NUMBER=your_twilio_sms_sender_number
Step 3: Example of config/twilio-sdk.php
return [ 'account_sid' => env('TWILIO_SID', ''), 'auth_token' => env('TWILIO_TOKEN', ''), 'wp_sender' => env('TWILIO_SENDER_NUMBER', ''), 'sms_sender' => env('TWILIO_SMS_NUMBER', ''), ];
๐ค Usage
โ Send Whatsapp Message
use Masrur447\TwilioSdk\Twilio; Twilio::sendWP('+8801234567890', 'Hello from Laravel Twilio SDK!', 'media url or null');
โ Send SMS
use Masrur447\TwilioSdk\Twilio; Twilio::sendSMS('+8801234567890', 'Hello from Laravel Twilio SDK!');
๐งช Easy way to use it just add trait in user model
use InteractsWithTwilio; $user = User::find(1); $user->notifyTwilioWhatsapp('Hellow from Laravel trait Twilio SDK', 'media url or null'); $user->notifyTwilioSMS('Hellow from Laravel trait Twilio SDK');
๐งช Example: Sending SMS from Controller
namespace App\Http\Controllers; use Illuminate\Http\Request; use Masrur447\TwilioSdk\Twilio; class SmsController extends Controller { public function send(Request $request) { Twilio::sendSMS($request->phone, $request->message); return response()->json([ 'status' => 'SMS sent successfully!', ]); } }
๐งช Example: Tinker Usage
php artisan tinker >>> Twilio::sendSMS('+8801234567890', 'Test SMS from tinker');
๐ Advanced Usage (Optional)
Coming soon...
๐ค Contributing
Contributions, issues, and feature requests are welcome!
Feel free to check issues page if you want to contribute.
๐งพ License
This project is open-sourced under the MIT license.
See the LICENSE file for more information.
๐ Author
Masrur โ GitHub
๐ Show your support
If you like this package, give it a โญ on the GitHub repo!