定制 clevyr/laravel-twilio-channel 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

clevyr/laravel-twilio-channel

最新稳定版本:v1.1.1

Composer 安装命令:

composer require clevyr/laravel-twilio-channel

包简介

A Laravel Notification channel for Twilio

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

A Laravel Notification channel for sending SMS messages with Twilio.

Installation

You can install the package via composer:

composer require clevyr/laravel-twilio-channel

Configure an account on Twilio, and then add the following env vars:

TWILIO_SID= TWILIO_AUTH_TOKEN= TWILIO_PHONE_NUMBER= 

Next, publish the config file with:

php artisan vendor:publish --provider="Clevyr\LaravelTwilioChannel\LaravelTwilioChannelServiceProvider"

This is the contents of the published config file (without descriptive comments):

return [ 'sid' => env('TWILIO_SID'), 'auth_token' => env('TWILIO_AUTH_TOKEN'), 'phone_number' => env('TWILIO_PHONE_NUMBER'), ];

Usage

In your Laravel notifications:

  • Implement the TwilioNotification interface
  • Add the TwilioChannel to your via return array value
  • Build a toTwilio function that returns a TwilioMessage object
<?php namespace App\Notifications; use Clevyr\LaravelTwilioChannel\Channels\TwilioChannel; use Clevyr\LaravelTwilioChannel\Contracts\TwilioNotification; use Clevyr\LaravelTwilioChannel\Messages\TwilioMessage; use Illuminate\Notifications\Notification; class MyNotification extends Notification implements TwilioNotification { /**  * Get the notification's delivery channels.  *  * @param mixed $notifiable  * @return array  */ public function via($notifiable) { return [TwilioChannel::class]; } /**  * Get the twilio representation of the notification.  *  * @param mixed $notifiable  * @return \Clevyr\LaravelTwilioChannel\Messages\TwilioMessage  */ public function toTwilio($notifiable) { return (new TwilioMessage) ->line('Your first line.') ->line('A second line, with a break between the last line.'); }

By default, TwilioChannel will use your notifiable's phone_number field to send an SMS message, which must be in a format such as 8884445555.

Overriding the Notifiable Phone Number Field

To override the phone_number and use a different field, set the twilioPhoneNumberField instance variable in your notifiable class:

class User extends Authenticatable { public $twilioPhoneNumberField = 'primary_phone_number'; // }

On-Demand Notifications

If you wish to send an on-demand notification, and not use a notifiable object at all, you can do that:

use Illuminate\Support\Facades\Notification; Notification::route('twilio', '5555555555') ->notify(new InvoicePaid($invoice)); 

Testing

composer test

Linting

composer analyse

Formatting w/ Laravel Pint

composer format

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 24.35k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 6
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固