1. Go to this page and download the library: Download macellan/twilio library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
macellan / twilio example snippets
// config/services.php
...
'sms' => [
'twilio' => [
'account_sid' => env('TWILIO_ACCOUNT_SID', ''),
'auth_token' => env('TWILIO_AUTH_TOKEN', ''),
'from' => env('TWILIO_FROM', ''),
'enable' => env('TWILIO_ENABLE', false),
'debug' => env('TWILIO_DEBUG', false), // Will log sending attempts and results
'sandbox_mode' => env('TWILIO_SANDBOX_MODE', false), // Will not invoke API call
],
],
...
use Illuminate\Notifications\Notification;
use Macellan\Twilio\TwilioSmsMessage;
class TestNotification extends Notification
{
public function via($notifiable)
{
return ['twilio'];
}
public function toTwilio(object $notifiable): TwilioSmsMessage
{
return new TwilioSmsMessage('Twilio test message');
}
}
public function routeNotificationForSms()
{
return $this->phone;
}