itxshakil/laravel-fast2sms
Laravel Fast2SMS is a complete Fast2SMS integration for Laravel, supporting SMS, OTP, DLT, and WhatsApp with a fluent, type-safe API. It includes Laravel Notifications, queue support, a powerful fake for testing, typed exceptions, and cost-saving safeguards.
Notifiable contracts), enabling unified messaging channels.database, redis), critical for scalability and reliability.Fast2sms::fake() now records the full outbound payload, so sentSms()[n]->parameters exposes variablesValues, senderId, entityId, templateId, language, flash, and scheduleTime in addition to numbers, message, and route.->parameters->variablesValues) and on DLT compliance fields — previously these assertions were impossible against the fake, forcing either brittle HTTP mocks or live-API smoke tests.user.registered) via notifications.parameters object is now more complete — a strictly additive change. Teams asserting on the absence of keys (unlikely, but possible with strict array comparisons) should re-run their suite.parameters shape? Those should be upgraded to assert on variablesValues/templateId/entityId before the value of v2.2.1 is realised.bus or horizon for async processing.curl calls, custom libraries).parameters shape.Fast2SMSChannel.Fast2SMS::send()).spatie/laravel-activitylog, laravel/breeze).composer update itxshakil/laravel-fast2sms. No config, migration, or env changes. Expected effort: minutes; re-run the test suite to confirm no assertions depended on the previous partial parameters payload..env:
FAST2SMS_API_KEY=your_key
FAST2SMS_SENDER_ID=your_sender
QUEUE_CONNECTION=redis).Notifiable to use Fast2SMSChannel:
use Itxshakil\Fast2Sms\Channels\Fast2SMSChannel;
class User extends Authenticatable implements Notifiable {
public function routeNotificationForFast2sms(): string {
return $this->phone;
}
}
// Old: curl to Fast2SMS API
// New:
Fast2SMS::send([
'message' => 'Hello!',
'numbers' => ['+1234567890'],
'type' => 'sms', // or 'whatsapp'
]);
config/fast2sms.php:
'driver' => env('FAST2SMS_DRIVER', 'fake'),
Fast2SMS::fake();
// trigger OTP flow...
$sent = Fast2SMS::sentSms()[0];
$sent->parameters->variablesValues; // OTP code
$sent->parameters->templateId; // DLT template
$sent->parameters->entityId; // DLT entity
$sent->parameters->senderId;
composer update).horizon) distribute load across servers.redis for queue backend).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Fast2SMS API outage | SMS/OTP delivery halts; login flows for OTP-only users break | Queue with retry/backoff; secondary provider behind a facade; user-facing fallback (email/voice OTP) |
| Rate limiting / throttling | Queued messages back up; delayed notifications | Throttle jobs (RateLimited middleware), monitor queue depth, upgrade Fast2SMS tier |
| Invalid or unregistered number | Silent non-delivery; failed OTP | Validate/normalise numbers pre-send; monitor callback/DLR webhooks; alert on failure-rate spikes |
| DLT template/entity mismatch | Message rejected at provider in India | Assert templateId/entityId/variablesValues in CI via the v2.2.1 fake; gate deployments on template config |
| API key expiry or rotation | All sends fail with auth errors | Runbook + secrets manager; alerting on 401/403 responses; staged key rotation |
| WhatsApp template rejection | WhatsApp channel unusable for affected templates | Pre-approve templates per Meta policy; monitor rejection webhooks; keep SMS fallback |
| Package abandonment | No upstream fixes for API drift | Internal fork under MIT; pin version in composer.json; quarterly review |
| Test/production divergence | Green CI but real sends fail (fake validates payload, not acceptance) | Maintain a small smoke-test suite against Fast2SMS sandbox/staging; rely on DLR callbacks for ground truth |
How can I help you explore Laravel packages today?