Weave 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

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.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Pros:
    • Laravel-native integration: Leverages Laravel’s service container, notifications, and queue systems, aligning with modern Laravel architectures (e.g., Lumen, Laravel 10+).
    • Fluent/Type-Safe API: Reduces boilerplate and improves developer experience (DX) for SMS/WhatsApp workflows.
    • Notification Support: Seamlessly integrates with Laravel’s built-in notification system (e.g., Notifiable contracts), enabling unified messaging channels.
    • Queue Integration: Supports async processing via Laravel queues (e.g., database, redis), critical for scalability and reliability.
    • Testing-Friendly: Includes a fake driver for unit/integration testing, reducing flakiness in CI/CD pipelines. Improved in v2.2.1: 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.
    • DLT/OTP assertability (v2.2.1): Teams can now assert on the actual OTP code (->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.
  • Cons:
    • Vendor Lock-in: Tight coupling with Fast2SMS API may complicate future provider migrations (e.g., switching to Twilio or AWS SNS).
    • Limited Customization: Fluent interface may restrict advanced use cases (e.g., custom HTTP clients, retry logic).
    • WhatsApp Limitations: Fast2SMS’s WhatsApp API may have rate limits or regional restrictions not addressed by the package.
    • Fake-only fidelity: v2.2.1 improves what the fake records, but it still does not simulate provider-side failures (rejections, DLT template mismatches, throttling). Negative-path coverage remains a build-your-own concern.

Integration Feasibility

  • High for Standard Use Cases:
    • SMS/Notifications: Ideal for transactional messages (OTPs, alerts) or marketing campaigns.
    • Event-Driven Workflows: Works well with Laravel events (e.g., user.registered) via notifications.
    • Queue Workers: Supports delayed/batched sends via Laravel queues.
    • OTP/DLT test suites (new in v2.2.1): Regression tests for OTP flows and India DLT templates can now assert on rendered message content and template identifiers without hitting the live API — a common blocker for teams shipping to the Indian market.
  • Moderate for Edge Cases:
    • Multi-Provider Setups: Requires additional abstraction (e.g., facade layer) if multiple SMS providers are needed.
    • WhatsApp Business API: May need custom logic for template-based messages or compliance (e.g., GDPR opt-ins).
    • Failure Injection: Simulating provider errors still requires custom fakes or HTTP-level mocking.

Technical Risk

  • Low-Medium:
    • API Stability: Fast2SMS’s API changes could break compatibility (monitor their changelog).
    • Rate Limits: Fast2SMS imposes limits (e.g., 1 SMS/sec for free tier); requires handling throttling in production.
    • Error Handling: Package’s exception hierarchy must be extended for custom recovery (e.g., retries, fallback providers).
    • WhatsApp Compliance: Risk of message rejections if templates or opt-in flows aren’t configured per Meta’s policies.
    • Release Risk (v2.2.1): Negligible. Patch-level, bug-fix only, no breaking changes, no public API surface changes. The only behavioural delta is that the fake’s 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.
    • False-confidence risk: Because assertions are now richer, there is a mild temptation to treat green fake-based tests as delivery validation. The fake validates payload construction only, not provider acceptance (DLT scrubbing, number validity, template approval status).

Key Questions

  1. Provider Lock-In:
    • How critical is flexibility to switch SMS providers? If high, consider wrapping this package in a provider-agnostic facade.
  2. Cost Management:
    • Are Fast2SMS’s pricing tiers sustainable for projected volume? Explore their bulk discounts.
  3. WhatsApp Use Case:
    • Is WhatsApp Business API required, or is Fast2SMS’s consumer API sufficient? The latter lacks template support.
  4. Testing Coverage (revisit in light of v2.2.1):
    • The earlier gap around asserting OTP/DLT payloads is now closed. Remaining question: does the team also need failure-path simulation (rejected numbers, DLT mismatch, throttling)? That still requires custom fakes or an HTTP client mock layer.
    • Are any existing tests asserting on the old three-key parameters shape? Those should be upgraded to assert on variablesValues/templateId/entityId before the value of v2.2.1 is realised.
  5. Monitoring:
    • How will delivery receipts/failures be logged? Fast2SMS provides callback URLs; integrate with Laravel’s logging or a tool like Sentry.
  6. Scalability:
    • For high-volume sends (>10K/month), evaluate Fast2SMS’s dedicated plans or alternative providers.

Integration Approach

Stack Fit

  • Ideal For:
    • Laravel 8+: Full feature support (notifications, queues, facades).
    • Lumen: Works but may require manual queue/config setup.
    • Livewire/Inertia: Useful for real-time SMS triggers (e.g., form submissions).
    • Event-Driven Apps: Pairs well with Laravel’s bus or horizon for async processing.
    • Regulated/India-facing products: v2.2.1 makes DLT entity/template IDs first-class in tests, which simplifies release gating for OTP and transactional templates.
  • Less Ideal For:
    • Non-Laravel PHP: Not applicable; requires Laravel’s service container.
    • Monolithic SMS Systems: If SMS is a core feature, consider a microservice with this package as a client.

Migration Path

  1. Assessment Phase:
    • Audit existing SMS/WhatsApp logic (e.g., curl calls, custom libraries).
    • Identify pain points (e.g., manual retries, no queue support).
    • Inventory existing tests that touch SMS; flag any that assert on the pre-2.2.1 three-key parameters shape.
  2. Pilot Integration:
    • Replace a single SMS use case (e.g., password resets) with the package.
    • Test the fake driver in CI and local development.
  3. Full Rollout:
    • Migrate notifications to use the package’s Fast2SMSChannel.
    • Replace direct API calls with the fluent interface (e.g., Fast2SMS::send()).
    • Configure queues for async sends (see Laravel Queues).
  4. Deprecation:
    • Phase out legacy SMS logic; update documentation.

Compatibility

  • Laravel Versions: Tested with Laravel 8–10 (check composer.json).
  • PHP Versions: Requires PHP 8.0+ (aligns with Laravel’s support).
  • Dependencies:
    • Guzzle HTTP client (included via Laravel).
    • No conflicts with popular packages (e.g., spatie/laravel-activitylog, laravel/breeze).
  • Database: No schema changes; uses Laravel’s config and queue tables.
  • v2.2.1 upgrade: Drop-in via 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.

Sequencing

  1. Configuration:
    • Publish and configure .env:
      FAST2SMS_API_KEY=your_key
      FAST2SMS_SENDER_ID=your_sender
      
    • Set up queue connection (e.g., QUEUE_CONNECTION=redis).
  2. Notification Setup:
    • Extend Notifiable to use Fast2SMSChannel:
      use Itxshakil\Fast2Sms\Channels\Fast2SMSChannel;
      
      class User extends Authenticatable implements Notifiable {
          public function routeNotificationForFast2sms(): string {
              return $this->phone;
          }
      }
      
  3. Sending Messages:
    • Replace direct API calls with fluent methods:
      // Old: curl to Fast2SMS API
      // New:
      Fast2SMS::send([
          'message' => 'Hello!',
          'numbers' => ['+1234567890'],
          'type' => 'sms', // or 'whatsapp'
      ]);
      
  4. Testing (expanded with v2.2.1 capability):
    • Configure fake driver in config/fast2sms.php:
      'driver' => env('FAST2SMS_DRIVER', 'fake'),
      
    • Assert on the full recorded payload, not just message/numbers:
      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;
      
    • Write tests for success/failure scenarios; note failure paths still need custom fakes or HTTP mocking.

Operational Impact

Maintenance

  • Pros:
    • MIT License: No legal restrictions; easy to fork/modify.
    • Active Development: Recent releases (2026) suggest ongoing maintenance.
    • Responsive fix cadence: v2.2.1 addresses a real-world testing papercut quickly and without breaking changes — a positive maintenance signal.
    • Documentation: README and changelog are comprehensive.
  • Cons:
    • Single Maintainer: Risk if the author becomes unresponsive (mitigate with internal forks).
    • Fast2SMS Dependency: Requires monitoring their API changes.
  • Tasks:
    • Quarterly dependency updates (composer update).
    • Review Fast2SMS’s status page for outages.
    • Update tests if Fast2SMS API responses change.
    • One-off for v2.2.1: upgrade test assertions to leverage the new payload fields; budget ~0.5–2 dev-days depending on how many SMS tests exist.

Support

  • Community:
    • Limited stars (20) may mean sparse community support; rely on GitHub issues.
    • Fast2SMS’s support handles API issues.
  • Internal Resources:
    • Document common errors (e.g., rate limits, invalid numbers) and solutions.
    • Create a runbook for:
      • API key rotations.
      • Queue backlog recovery.
      • WhatsApp template approvals.
      • DLT template/entity ID changes (now assertable in CI, so stale IDs surface at build time rather than at send time).
  • SLAs:
    • Define response times for SMS delivery failures (e.g., <4h for critical alerts).

Scaling

  • Horizontal Scaling:
    • Queue workers (e.g., horizon) distribute load across servers.
    • Monitor queue length to scale workers (e.g., redis for queue backend).
  • Vertical Scaling:
  • Performance:
    • Benchmark send times under load (e.g., 1000 messages/min).
    • Cache sender IDs/API keys if using multiple environments.
  • Test-suite scaling: Richer fake payloads mean broader assertion coverage without additional HTTP mocking; CI cost is unchanged since the fake remains in-process and network-free.

Failure Modes

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
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.
oxygen/data
oxygen/core
jengo/base
xiloryx/log-collector
a21ns1g4ts/filament-stripe
la-php/laravel-admin
artisan-build/community-prompts
vleroy/smart
ayles-software/laravel-australian-public-holidays
cboxdk/laravel-id-spatie
cboxdk/laravel-id-billing
cboxdk/laravel-id-billing-bridge
simple-as-fuck/php-performance-log
hsluv/hsluv
seampact/codegen
seampact/hooks
seampact/ir
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table