Download the PHP package 1naturalway/laravel-sms without Composer
On this page you can find all versions of the php package 1naturalway/laravel-sms. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download 1naturalway/laravel-sms
More information about 1naturalway/laravel-sms
Files in 1naturalway/laravel-sms
Package laravel-sms
Short Description A driver-based SMS abstraction layer for Laravel, following the MailManager pattern.
License MIT
Informations about the package laravel-sms
Laravel SMS
A driver-based SMS abstraction layer for Laravel, following the same architectural pattern as Laravel's built-in Mail system. Swap between Twilio, logging, or a null driver with a single config change.
Installation
Publish the config file:
Configuration
Set the driver and credentials in your .env file:
Twilio
Requires the Twilio SDK:
Log
Writes every SMS to a Laravel log channel. Useful for debugging and verifying sends in staging or CI.
Null
Silently discards all messages. This is the default — no accidental sends in development.
Usage
Basic Send
Every send() call returns an SmsResult DTO with these properties:
| Property | Type | Description |
|---|---|---|
messageId |
?string |
Provider message ID (e.g., Twilio SID) |
status |
?string |
Provider status (e.g., queued, captured, logged) |
to |
?string |
Recipient number |
from |
?string |
Sender number |
body |
?string |
Message body |
mediaCount |
?int |
Number of media attachments (Twilio) |
mediaUrls |
array |
URLs of attached media (Twilio MMS) |
raw |
array |
Full raw response from the provider |
Use $result->successful() to check if the message was accepted — returns true when messageId is present. Use $result->hasMedia() to check if media was attached. The null driver always returns an unsuccessful result since nothing was sent.
Error Handling
The Twilio driver wraps API errors into typed SmsException instances so you can handle specific failure modes:
SmsException extends RuntimeException, so uncaught errors will still surface normally in your exception handler.
With Options
Driver Switching
Dependency Injection
Testing
The package ships with a FakeSmsProvider that captures all messages in memory, just like Laravel's Mail::fake().
Available Assertions
| Method | Description |
|---|---|
assertSentTo($number, $bodyContains?) |
A message was sent to this number, optionally containing text |
assertNothingSent() |
No messages were sent |
assertSentCount($n) |
Exactly N messages were sent |
assertSentToWithBody($number, $callback) |
A message to this number passes the callback (receives SmsResult) |
getSent() |
Returns an array of SmsResult objects |
Custom Drivers
Register a custom driver using extend(), typically in a service provider's boot() method:
Add the driver config to config/sms.php:
Your custom provider must implement the SmsProvider interface:
UAT Strategy
For UAT environments, we recommend Log driver:
- Log writes messages to your Laravel log files for easy inspection. Use
SMS_DRIVER=logwhen you need to verify sends in CI or staging. - Null (the default) ensures no SMS is sent in development or CI unless explicitly configured.
This layered approach guarantees:
- Production uses Twilio (or your chosen carrier) via
SMS_DRIVER=twilio - UAT uses logs to capture and inspect messages
- Development and CI use
nullorlog— zero accidental sends
License
MIT
All versions of laravel-sms with dependencies
illuminate/support Version ^12.0 || ^13.0
illuminate/contracts Version ^12.0 || ^13.0
illuminate/http Version ^12.0 || ^13.0
illuminate/log Version ^12.0 || ^13.0