Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Fast2Sms Laravel Package

itxshakil/laravel-fast2sms

View on GitHub
Deep Wiki
Context7
v2.0.0

🚀 What's New in v2.0.0

This is a major release of laravel-fast2sms focused on WhatsApp Business API support, a richer exception hierarchy, expressive testing utilities, and modern PHP 8.3+ patterns throughout.

⚠️ This release contains breaking changes. Please read the Upgrade Guide before updating.


Highlights

🚀 WhatsApp Business API — Send text, image, document, location, interactive, reaction, sticker, and template messages via Fast2sms::viaWhatsApp().

🔔 Laravel Notification Channels — Drop-in SmsChannel and WhatsAppChannel for use with Laravel's built-in notification system.

🧱 Typed Exception Hierarchy — Catch exactly what you need: AuthenticationException, RateLimitException, ServerException, NetworkException, ValidationException, ConfigurationException, DuplicateSendException, InsufficientBalanceException, ThrottleExceededException.

🧪 Rich Fake Assertions — 16 new Fast2smsFake assertion methods for expressive, readable test code. Plus stopFaking() for clean test teardown.

💡 Fluent Message BuildersSmsMessage and WhatsAppMessage with named constructors and chainable setters. SmsMessage also ships with credit helpers: charCount(), isUnicode(), creditCount(), exceedsOneSms().

⚙️ New Artisan Commands

  • fast2sms:events — lists all dispatchable events with descriptions
  • fast2sms:ide-helper — generates _ide_helper_fast2sms.php for full IDE autocompletion

📦 Queue SupportonQueue() / onConnection() fluent API with built-in validation.

🧩 PHP 8.3+ Patternsreadonly class DTOs, backed enums, and typed returns throughout.

🐘 PHP 8.4 & 8.5 Support — CI matrix extended and fully tested.

🌐 Laravel 13 Support — Compatible with Laravel 11, 12, and 13.


Cost-Saving Guards (all opt-in via config/env)

Guard Config Key What it does
Recipient deduplication fast2sms.recipients.deduplicate Strips duplicate numbers before every send
Invalid recipient stripping fast2sms.validation.strip_invalid_recipients Validates numbers, logs warnings, throws if all invalid
Idempotency guard fast2sms.deduplication.* Blocks repeated (recipients + message + route) within a TTL window
Rate throttle fast2sms.throttle.* Sliding-window per-minute cap via Laravel cache
Balance gate fast2sms.balance_gate.* Checks wallet before send; fires LowBalanceDetected, optionally throws
Batch splitting fast2sms.recipients.batch_size Splits large recipient lists into chunks automatically

Breaking Changes ⚠️

Fast2smsException is now final Extend a specific subtype (ApiException, NetworkException, etc.) instead.

DTOs are readonly class Fast2smsConfig, SmsParameters, and WhatsAppParameters properties cannot be mutated after construction — reconstruct the DTO instead.

ConfigValidator::validate() now throws ConfigurationException instead of \InvalidArgumentException — update your catch blocks.

ResponseFactory throws ApiException on unknown response types instead of UnhandledMatchError.

Fast2smsFake recorded calls are typed value objects Use sentSms() / sentWhatsApp() accessors instead of accessing $fake->recorded directly.

SmsChannel / WhatsAppChannel throw \LogicException when the notifiable is missing the required routing method — implement routeNotificationForFast2sms() / routeNotificationForWhatsapp().

All public API methods now return ResponseInterface instead of the concrete Fast2smsResponse — update type-hints accordingly.

The public sending API — Fast2sms::quick(), ::dlt(), ::otp(), ::viaWhatsApp() — is completely unchanged.


Deprecations

These methods still work but will be removed in v3.0.0:

Deprecated Replacement
SmsMessage::content() SmsMessage::withContent()
SmsMessage::route() SmsMessage::withRoute()
SmsMessage::to() SmsMessage::withNumbers()

Bug Fixes

  • HttpClient no longer retries on 4xx — only 5xx and connection failures
  • ResponseFactory no longer throws UnhandledMatchError on unknown response types
  • ManagesSms::setDlt no longer overwrites the message body with the DLT template ID
  • HttpClient::upload now guards against missing or unreadable files with a descriptive exception
  • SendRateThrottle replaced non-atomic cache pattern with RateLimiter to eliminate a race condition
  • AppliesSendGuards writes the dedup cache only after a successful send, so failed sends don't block retries
  • Fast2smsServiceProvider::boot now correctly skips config validation only during unit tests, not all console commands
  • ManagesWhatsAppActions dispatches WhatsAppFailed on exception
  • LowBalanceDetected now correctly uses Dispatchable + SerializesModels
  • Null-dereference on first-chunk failure in ManagesSms::executeSend is now a descriptive Fast2smsException
  • Double afterApiCall() trigger in executeApiCall finally block removed

Test Coverage

v1.x v2.0.0
Tests 88 229
Assertions 453

New coverage includes DTOs, enums, exceptions, responses, events, jobs, channels, fake assertions, and LogClient.


Upgrade Guide

See UPGRADING.md for a step-by-step migration guide from v1.x to v2.0.0.


Full Changelog: https://github.com/itxshakil/laravel-fast2sms/blob/main/CHANGELOG.md

v1.3.0
  • Observability & Logging:
    • Optional database-backed logging system with fast2sms_logs table.
    • New LogSmsSent and LogSmsFailed event listeners.
    • log driver for local development to prevent credit wastage.
  • Resilience:
    • Automatic retries using Laravel's Http::retry() (3 attempts, 100ms backoff).
    • Config validation during boot with clear Fast2smsException.
  • Developer Experience (DX):
    • Enhanced SmsChannel to support SmsMessage objects with recipient data.
    • Fluent to() and send() methods in SmsMessage.
    • Support for Laravel Collection in to() method.
    • Custom Fast2smsPhone validation rule for Indian mobile numbers.
    • Improved Fast2smsResponse with dynamic property access and json() method.
  • Testing:
    • Added comprehensive tests for database logging, log driver, retries, config validation, and the new validation rule.
v1.1.0

What's Changed

Full Changelog: https://github.com/itxshakil/laravel-fast2sms/compare/v1.0.0...v1.1.0

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium