Twilio
Twilio stats
- Downloads
- 3M
- Stars
- 196
- Open Issues
- 19
- Forks
- 29
Provides Twilio notification channel for Laravel
Twilio Notifications Channel for Laravel
The Twilio Notifications Channel for Laravel enables convenient integration with Twilio for sending notifications via SMS, MMS, or voice calls. This package is compatible with Laravel versions 5.5 and higher, including the latest releases.
Main Features
- Send SMS, MMS, and Voice Calls: Easily send notifications as text messages, multimedia messages, or voice calls.
- Flexible Notification Routing: Decide how notifications are sent based on notifiable entities in your application.
- Configurable Error Handling: Choose to log specific errors or suppress all errors for streamlined debugging and production readiness.
- Advanced Configuration Options: Customize behavior through environmental variables or a published configuration file.
- Support for Twilio’s Messaging Services: Utilize features like Advanced Opt-Out, Sticky Sender, and Smart Encoding by configuring a Messaging Service SID.
Installation and Configuration
-
Installation via Composer:
composer require laravel-notification-channels/twilio -
Environment Configuration: Add Twilio credentials to your
.envfile:TWILIO_ACCOUNT_SID=1234TWILIO_AUTH_TOKEN=ABCDTWILIO_FROM=100000000 -
Publish Configuration (optional for advanced settings):
php artisan vendor:publish --provider="NotificationChannels\Twilio\TwilioProvider"
Usage
Implement notifications in your Laravel application using Twilio by specifying TwilioChannel in the via() method of your notification class. You can send SMS, MMS, or initiate Twilio calls:
use NotificationChannels\Twilio\TwilioSmsMessage;use NotificationChannels\Twilio\TwilioMmsMessage;use NotificationChannels\Twilio\TwilioCallMessage;use Illuminate\Notifications\Notification; class AccountApproved extends Notification{ public function via($notifiable) { return [TwilioChannel::class]; } public function toTwilio($notifiable) { return (new TwilioSmsMessage()) ->content("Your account was approved!"); }}
Additional Details
- Error Handling: Manage how errors are reported by editing the
ignored_error_codesin the published configuration file. - Testing and Security: Run tests using
composer test. Report security issues directly via the provided email. - Upgrading: When upgrading from version 2.x to 3.x, ensure your environmental settings are correctly aligned with the new requirements.
This package is maintained by a community of contributors and is licensed under the MIT License. For a comprehensive guide, including a list of available message methods and detailed configuration options, refer to the full package documentation.