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

Smsapi Notifier Laravel Package

symfony/smsapi-notifier

Symfony Notifier bridge for SMSAPI (smsapi.pl / smsapi.com). Send SMS using an OAuth token via DSN config, with options for sender name, fast delivery priority, and test mode.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Laravel-Symfony Synergy: The package is designed for Symfony’s Notifier component, which can be integrated into Laravel via spatie/laravel-notifier or spatie/laravel-symfony-messenger. This provides a clean abstraction for SMS notifications without tightly coupling to Symfony’s ecosystem.
  • Modularity: The bridge follows Symfony’s DSN (Data Source Name) pattern, allowing configuration via environment variables (e.g., SMSAPI_DSN). This aligns well with Laravel’s .env and dependency injection systems.
  • Use Case Alignment:
    • Transactional SMS: Ideal for OTPs, alerts, or confirmations.
    • Event-Driven Workflows: Works seamlessly with Laravel’s queues (via Symfony Messenger) or events.
    • Multi-Channel Notifications: Can complement existing email/SMS hybrid systems if SMSAPI is the preferred SMS provider.

Integration Feasibility

  • Dependency Requirements:
    • Core: symfony/notifier:^6.0 (or ^7.0 for newer Laravel apps).
    • Laravel Bridge: spatie/laravel-notifier (if not already using Symfony Notifier).
    • Optional: symfony/messenger for async processing (if Laravel queues are in use).
  • Configuration:
    • DSN Format: Supports environment variables (e.g., .env):
      SMSAPI_DSN=smsapi://API_TOKEN@api.smsapi.com?from=SenderName&fast=1
      
    • Laravel Service Provider: Register the transport in config/services.php or a custom provider.
  • Code Changes:
    • Replace manual SMS logic (e.g., Http::post() calls) with Symfony’s SmsMessage:
      use Symfony\Component\Notifier\Message\SmsMessage;
      use Symfony\Component\Notifier\NotifierInterface;
      
      $notifier = app(NotifierInterface::class);
      $notifier->send(new SmsMessage('Recipient', 'Hello!'));
      
    • Event Listeners: Extend with Laravel’s Illuminate\Events\Dispatcher for post-send hooks.

Technical Risk

Risk Area Severity Mitigation Strategy
Symfony Version Mismatch Medium Pin symfony/notifier to a stable version (e.g., ^6.4) to avoid breaking changes.
SMSAPI API Instability High Implement retry logic (e.g., spatie/laravel-retryable) and circuit breakers.
Laravel-Symfony DI Conflicts Low Use spatie/laravel-symfony-messenger to resolve dependency conflicts.
Testing Complexity Medium Mock SMSAPI responses with Pest/Mockery or use SMSAPI’s sandbox mode.
Cost Overruns Medium Monitor SMS usage via SMSAPI’s dashboard and set budget alerts.

Key Questions

  1. Is Symfony Notifier already in use?
    • If yes, integration is minimal (1–2 days).
    • If no, evaluate whether to adopt it or build a lightweight SMSAPI client.
  2. What’s the SMS delivery SLA?
    • SMSAPI’s "fast" mode costs more; ensure SLAs align with business needs.
  3. Are there existing SMS providers?
    • Avoid provider fragmentation; consolidate if possible.
  4. How are failures handled?
    • Ensure retries, dead-letter queues, and alerts (e.g., Laravel’s Sentry).
  5. Is SMSAPI’s sandbox mode sufficient for testing?
    • Verify if test mode (?test=1) meets QA requirements.

Integration Approach

Stack Fit

  • Ideal for:
    • Laravel apps using Symfony Notifier (spatie/laravel-notifier).
    • Projects leveraging Laravel Queues (via Symfony Messenger).
    • Systems requiring audit logs or delivery tracking for SMS.
  • Workarounds:
    • Non-Symfony Laravel Apps: Use a custom SMSAPI client (Guzzle-based) or wrap the bridge in a Laravel service.
    • Hybrid Systems: Combine with spatie/laravel-notification-channels for multi-channel support.

Migration Path

  1. Phase 1: Assessment (1–2 days)
    • Audit existing SMS logic (e.g., manual HTTP calls, third-party libraries).
    • Decide: Adopt Symfony Notifier or build a lightweight client.
  2. Phase 2: Setup (2–3 days)
    • Option A (Symfony Notifier):
      • Install dependencies:
        composer require symfony/notifier spatie/laravel-notifier symfony/smsapi-notifier
        
      • Configure .env:
        SMSAPI_DSN=smsapi://API_TOKEN@api.smsapi.com?from=SenderName
        
      • Register the transport in config/services.php:
        'notifier' => [
            'transports' => [
                'smsapi' => env('SMSAPI_DSN'),
            ],
        ],
        
    • Option B (Custom Client):
      • Create a SmsapiService class:
        use GuzzleHttp\Client;
        
        class SmsapiService {
            public function __construct(private Client $client) {}
        
            public function send(string $to, string $message): bool {
                $response = $this->client->post('https://api.smsapi.com/sms', [
                    'auth' => [env('SMSAPI_KEY'), ''],
                    'json' => ['to' => $to, 'text' => $message],
                ]);
                return $response->getStatusCode() === 200;
            }
        }
        
      • Bind to Laravel’s container:
        $this->app->singleton(SmsapiService::class, fn() => new SmsapiService(new Client()));
        
  3. Phase 3: Implementation (3–5 days)
    • Replace manual SMS calls with SmsMessage (Symfony Notifier) or SmsapiService.
    • Example:
      // Using Symfony Notifier
      $notifier->send(new SmsMessage('+123456789', 'Your OTP: 12345'));
      
      // Using Custom Service
      app(SmsapiService::class)->send('+123456789', 'Your OTP: 12345');
      
    • Add event listeners for post-send analytics:
      use Symfony\Component\Notifier\EventListener\SentMessageListenerInterface;
      
      class SmsSentListener implements SentMessageListenerInterface {
          public function onMessageSent(object $message): void {
              // Log or dispatch Laravel events
          }
      }
      

Compatibility

  • Laravel Versions: Compatible with Laravel 9+ (PHP 8.1+) due to Symfony’s PHP 8.4 requirement in v8.0.
  • Symfony Versions: Prefer ^6.4 for stability; ^7.0 for newer features.
  • SMSAPI API: Verify compatibility with SMSAPI’s latest API (e.g., webhooks, template IDs).

Sequencing

  1. Start with a single use case (e.g., OTPs) to validate integration.
  2. Gradually replace manual SMS logic across the codebase.
  3. Add monitoring (e.g., Laravel Horizon for queue jobs) before full rollout.
  4. Phase out legacy SMS providers if consolidating.

Operational Impact

Maintenance

  • Dependencies:
    • Monitor symfony/notifier and symfony/smsapi-notifier for updates.
    • Use Composer scripts to auto-update dependencies:
      "scripts": {
        "post-update-cmd": "php artisan config:clear"
      }
      
  • Configuration Drift:
    • Centralize SMSAPI credentials in .env and use Laravel Forge/Envoyer for deployments.
    • Example .env template:
      SMSAPI_DSN=smsapi://${SMSAPI_TOKEN}@${SMSAPI_ENDPOINT}?from=${SMSAPI_SENDER}
      

Support

  • Troubleshooting:
    • Symfony Notifier Logs: Enable debug mode:
      $notifier->send(..., ['debug' => true]);
      
    • SMSAPI Dashboard: Monitor delivery stats and errors.
  • Common Issues:
    • Authentication Failures: Double-check SMSAPI_DSN format.
    • Rate Limiting: Implement exponential backoff for retries.
    • Character Limits: SMSAPI enforces 160
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.
ilhamsyabani/laravel-volt-starter
thethunderturner/filament-latex
ghostcompiler/laravel-querybuilder
webrek/laravel-telescope-mongodb
anousss007/blatui
zatona-eg/zatona-eg-api
cocosmos/filament-sticky-save-bar
patrickbussmann/oauth2-apple
3brs/enterprise-security-bundle
anousss007/vigilance
supportpal/eloquent-model
ardenexal/fhir-models
laravel-at/laravel-image-sanitize
romalytar/yammi-audit-log-laravel
ardenexal/fhir-validation
arshaviras/weather-widget
laravel-chronicle/core
sunchayn/nimbus
daikazu/eloquent-salesforce-objects
unseen-codes/chat