Download the PHP package justcoded/laravel-notification-channel-twilio without Composer
On this page you can find all versions of the php package justcoded/laravel-notification-channel-twilio. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-notification-channel-twilio
Twilio notifications channel for Laravel
Contents
- Installation
- Usage
- Available Message methods
Installation
You can install the package via composer:
Configuration
Add your Twilio Account SID, Auth Token, and From Number (optional) to your .env
:
Advanced configuration
Run php artisan vendor:publish --provider="Justcoded\NotificationChannelTwilio\TwilioProvider"
Suppressing specific errors or all errors
Publish the config using the above command, and edit the ignored_error_codes
array. You can get the list of
exception codes from the documentation.
If you want to suppress all errors, you can set the option to ['*']
. The errors will not be logged but notification
failed events will still be emitted.
Recommended Configuration
Twilio recommends always using a Messaging Service because it gives you access to features like Advanced Opt-Out, Sticky Sender, Scaler, Geomatch, Shortcode Reroute, and Smart Encoding.
Having issues with SMS? Check Twilio's best practices.
Upgrading from 2.x to 3.x
If you're upgrading from version 2.x
, you'll need to make sure that your set environment variables match those above
in the config section. None of the environment variable names have changed, but if you used different keys in your
services.php
config then you'll need to update them to match the above, or publish the config file and change the
env
key.
You should also remove the old entry for twilio
from your services.php
config, since it's no longer used.
The main breaking change between 2.x
and 3.x
is that failed notification will now throw an exception unless they are
in the list of ignored error codes (publish the config file to edit these).
You can replicate the 2.x
behaviour by setting 'ignored_error_codes' => ['*']
, which will case all exceptions to be
suppressed.
Usage
Now you can use the channel in your via()
method inside the notification:
You can also send an MMS:
Or create a Twilio call:
In order to let your Notification know which phone are you sending/calling to, the channel will look for the phone_number
attribute of the Notifiable model. If you want to override this behaviour, add the routeNotificationForTwilio
method to your Notifiable model.
Available Message methods
TwilioSmsMessage
from('')
: Accepts a phone to use as the notification sender.content('')
: Accepts a string value for the notification body.messagingServiceSid('')
: Accepts a messaging service SID to handle configuration.
TwilioCallMessage
from('')
: Accepts a phone to use as the notification sender.url('')
: Accepts an url for the call TwiML.
All versions of laravel-notification-channel-twilio with dependencies
twilio/sdk Version ~6.0
illuminate/notifications Version ^5.8 || ^6.0 || ^7.0 || ^8.0
illuminate/support Version ^5.8 || ^6.0 || ^7.0 || ^8.0
illuminate/events Version ^5.8 || ^6.0 || ^7.0 || ^8.0
illuminate/queue Version ^5.8 || ^6.0 || ^7.0 || ^8.0