Package: templates-sms
Generated from api/packages/templates-sms
Source: api/packages/templates-sms · imported version 0.1.12. The sections after the README are extracted from the code on every docs build.
README
Section titled “README”What does it do
Section titled “What does it do”Package for sms notifications with editable templates (for important user-related events). This package supports sending sms via twilio.
Installing
Section titled “Installing”composer require ulams/templates-smsphp artisan db:seed --class="Ulams\Templates-SMS\Database\Seeders\TemplateSmsSeeder"
Configuration
Section titled “Configuration”You can configure the connection to Twilio through keys in the .env file:
TWILIO_SID- twilio SID unique keyTWILIO_TOKEN- twilio auth tokenTWILIO_FROM- twilio phone numberTWILIO_SSL_VERIFY- twilio ssl verify
You can also change the default driver in SMS_DRIVER
Example
Section titled “Example”Sending SMS
Section titled “Sending SMS”Sending an SMS using the Sms facade
Sms::driver('twilio')->send('123456789', 'SMS message');or
Sms::send('123456789', 'SMS message');Custom driver
Section titled “Custom driver”You can define your own driver for sending sms. The driver must implement the interface \Ulams\TemplatesSms\Drivers\Contracts\SmsDriver.
interface SmsDriver{ public function send(string $to, string $content, array $mediaUrls = [], array $params = []): bool;}Example custom driver:
class CustomDriver implements \Ulams\TemplatesSms\Drivers\Contracts\SmsDriver{ public function send(string $to, string $content, array $mediaUrls = [], $params = []): bool { // Implement send() method. }}Register a new driver, we would do the following:
Sms::extend('custom', function($app) { return new CustomDriver($app);});Run ./vendor/bin/phpunit to run tests. See tests folder as it’s quite good staring point as documentation appendix.
This package has a facade for testing. The Sms facade’s fake method allows you to easily a fake sms driver.
public function testSms() { Sms::fake(); ... $service->sendSms($phone1); ... Sms::assertSent($phone1); Sms::assertNotSent($phone2);}public function testSms() { Sms::fake(); ... Sms::assertSent($phone1, fn($sms) => $sms->content === 'Sms message');}More documentation in the package
Section titled “More documentation in the package”API endpoints
Section titled “API endpoints”None.
Permissions
Section titled “Permissions”None.
Settings
Section titled “Settings”Registered with AdministrableConfig::registerConfig (editable in the admin panel under Configuration → Settings).
| Key | Rules | Public | Read-only |
|---|---|---|---|
sms.default |
required, string, in: . implode(,, SmsDriversEnum::getValues()) | no | |
sms.drivers.requestbin.path |
string | no | |
sms.drivers.twilio.sid |
string | no | |
sms.drivers.twilio.token |
string | no | |
sms.drivers.twilio.from |
string | no |
Events
Section titled “Events”None.
Notification templates registered here
Section titled “Notification templates registered here”| Event | Channel | Variables |
|---|---|---|
ApprovedTermWithTrainer |
Sms | ApprovedTermWithTrainerVariables |
ReportTerm |
Sms | ReportTermVariables |
RejectTermWithTrainer |
Sms | RejectTermWithTrainerVariables |
RejectTerm |
Sms | RejectTermVariables |
ApprovedTerm |
Sms | ApprovedTermVariables |
ReminderAboutTerm |
Sms | ReportTermVariables |
ReminderTrainerAboutTerm |
Sms | ReminderTrainerAboutTermVariables |
ManuallyTriggeredEvent |
Sms | UserVariables |
Artisan commands
Section titled “Artisan commands”None.
Scheduled jobs
Section titled “Scheduled jobs”None.
Environment variables read
Section titled “Environment variables read”None.