laravel-liberu / laravel-twilio
Laravel Twilio Package
Fund package maintenance!
collinped
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 0
Type:project
Requires
- php: ^8.1
- ext-json: *
- guzzlehttp/guzzle: ^7.4
- twilio/sdk: ^6.0
Requires (Dev)
- brianium/paratest: ^6.2
- laravel/pint: ^1.2
- nunomaduro/collision: ^6.1
- orchestra/testbench: ^7.0
- phpunit/phpunit: ^9.3
- spatie/laravel-ray: ^1.23
- vimeo/psalm: ^4.8
This package is auto-updated.
Last update: 2024-12-13 04:25:18 UTC
README
laravel-twilio
UNDER CONSTRUCTION - Laravel Twilio SDK/API Integration
Installation
Begin by installing this package through Composer. Run this command from the Terminal:
composer require collinped/laravel-twilio
If you're using Laravel 5.5+, this is all there is to do.
Should you still be on older versions of Laravel, the final steps for you are to add the service provider of the package and alias the package. To do this open your config/app.php
file.
Integration for older versions of Laravel (5.5 -)
To wire this up in your Laravel project, you need to add the service provider.
Open app.php
, and add a new item to the providers array.
'Collinped\Twilio\TwilioServiceProvider',
This will register a new artisan command for you:
twilio:video-room NAME
twilio:video-participants SID
Configuring the package
You can publish the config file with:
php artisan vendor:publish --provider="Collinped\Twilio\TwilioServiceProvider" --tag="config"
This is the contents of the file that will be published at config/twilio.php
Insert the following values into your .env
TWILIO_AUTH_TOKEN= TWILIO_ACCOUNT_SID= TWILIO_API_KEY= TWILIO_API_SECRET=
See Twilio Settings for instructions on how to get these values.
Taking care of routing
Finally, let's take care of the routing. At the app that sends webhooks, you probably configure an URL where you want your webhook requests to be sent. In the routes file of your app (web.php), you must pass that route to Route::post
or Route::get
depending on your specified method. Here's an example:
Route::post('webhook/twilio-video', 'TwilioVideoWebhookController@handleWebhook')->name('twilio.video.webhook'); Route::post('webhook/twilio-voice', 'TwilioVoiceWebhookController@handleWebhook')->name('twilio.voice.webhook'); Route::post('webhook/twilio-sms', 'TwilioSmsWebhookController@handleWebhook')->name('twilio.sms.webhook'); Route::post('webhook/twilio-fax', 'TwilioFaxWebhookController@handleWebhook')->name('twilio.fax.webhook');
Behind the scenes, this will register a POST
or GET
route to a controller provided by this package. Because the app that sends webhooks to you has no way of getting a csrf-token, you must add that route to the except
array of the VerifyCsrfToken
middleware:
protected $except = [ 'webhook/twilio/*', // All Twilio Webhooks ];
Or whitelist each endpoint individually based on your application
protected $except = [ 'webhook/twilio/video', // Twilio Video Webhooks 'webhook/twilio/voice', // Twilio Voice Webhooks 'webhook/twilio/voice-recording', // Twilio Voice Recording Webhooks 'webhook/twilio/sms', // Twilio SMS Webhooks 'webhook/twilio/conversations', // Twilio Conversations Webhooks ];
Twilio Video Settings
If you have an existing Twilio account login to your console or sign up here for your free trial account: Register for Twilio
- Navigate to "Programmable Video"
- Navigate to "Rooms"
- Navigate to "Settings"
- Set the method as "HTTP POST"
- Input your "Status Callback URL" as:
yourdomain.com/webhook/twilio/video
Laravel Twilio Roadmap
- Twilio Voice
- Twilio SMS
- Twilio Video
- Twilio Phone Numbers
- Twilio Short Codes
- Twilio Conversations
- Twilio Verify
- Twilio Verify Email - Sendgrid
- Twilio Programmable Wireless
- Twilio Proxy
- Twilio Lookup
- Twilio Flex
- Twilio Assistant
License
laravel-twilio is open-sourced software licensed under the MIT license