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

Fake Sms Notifier Laravel Package

symfony/fake-sms-notifier

Symfony Notifier transport that fakes SMS delivery during development. Redirect SMS messages to email (with configurable to/from and optional custom mailer transport) or log them via a logger DSN, without sending real texts.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Symfony Notifier Dependency: The package is tightly coupled with Symfony’s Notifier component, which is not natively integrated into Laravel. While Laravel supports Symfony components via bridges (e.g., symfony/mailer), introducing Symfony Notifier adds complexity and potential conflicts with Laravel’s existing notification system.
  • Use Case Alignment: Perfect for development/testing environments where SMS gateways are unnecessary. The dual output modes (email/logger) provide flexibility for debugging and QA.
  • Laravel Compatibility: Requires abstraction layers to bridge Laravel’s Notification facade with Symfony Notifier. This could involve:
    • Creating a custom Laravel channel driver for fake SMS.
    • Wrapping Symfony Notifier in a Laravel service to mediate between the two systems.

Integration Feasibility

  • Minimal Code Changes: If Symfony Notifier is already in use, integration is straightforward via DSN configuration. For pure Laravel, a custom adapter is required to translate Laravel’s Notification calls to Symfony Notifier.
  • DSN Configuration: Environment variable-based setup (FAKE_SMS_DSN) aligns with Laravel’s .env pattern, reducing friction.
  • Example Integration Path:
    // 1. Install dependencies
    composer require symfony/notifier symfony/fake-sms-notifier
    
    // 2. Configure in .env
    FAKE_SMS_DSN=fakesms+email://default?to=dev@example.com&from=test-sms
    
    // 3. Create a Laravel service to bridge Notifications
    class FakeSmsService {
        public function send(SmsNotification $notification) {
            $notifier = new \Symfony\Component\Notifier\Notifier([
                new \Symfony\Component\Notifier\Bridge\FakeSms\FakeSmsTransportFactory()
            ]);
            $notifier->sendSms($notification->phone, $notification->message);
        }
    }
    

Technical Risk

  • Dependency Overhead: Introduces Symfony Notifier (~50+ dependencies), which may conflict with existing Laravel packages or increase bundle size. Risk of version mismatches with other Symfony components.
  • Laravel-Symfony Friction: Laravel’s Notification system uses channels and events, while Symfony Notifier uses transports. Mapping these requires custom abstraction logic, increasing maintenance burden.
  • Limited Laravel Ecosystem Support: No native Laravel integrations (e.g., no via() method support for Laravel Notifications). May require forking or extending the package.
  • PHP Version Constraints: Requires PHP ≥8.1 (Symfony 7+) and ≥8.4 for v8.0. Laravel’s supported PHP versions (8.1–8.3) may cause compatibility issues with newer Symfony releases.
  • Testing Complexity: If the package replaces existing mock SMS services (e.g., laravel-notification-testing), teams may need to rewrite tests or adapt to new behavior.

Key Questions

  1. Is Symfony Notifier already in use? If yes, integration is trivial. If no, evaluate the cost of adding it and potential conflicts.
  2. Do we need a Laravel-native solution? If so, assess whether a custom channel driver or wrapper service is feasible within the team’s capacity.
  3. What’s the fallback for production? Ensure real SMS providers (Twilio, AWS SNS, etc.) are configured separately and that the fake SMS system does not leak into production.
  4. How will logs/emails be routed? For fakesms+logger, logs may clutter Laravel’s default channels. Consider a dedicated log channel (e.g., single or daily) for fake SMS.
  5. Testing Scope: Will this replace existing mock SMS services? Evaluate overlap with packages like laravel-notification-testing or mocksms.
  6. Performance Impact: Does the added dependency overhead affect composer install times or runtime performance? Benchmark if critical.
  7. Long-Term Maintenance: Who will own the abstraction layer between Laravel and Symfony Notifier? Is this a sustainable investment?

Integration Approach

Stack Fit

  • Symfony Notifier + Laravel: Best suited for Laravel applications already using Symfony components (e.g., Symfony Mailer, HTTP Client). If the stack is pure Laravel, integration requires a custom bridge to translate Laravel’s Notification system to Symfony Notifier.
  • Laravel Notifications: Requires a custom channel driver to integrate with Laravel’s Notification facade. Example architecture:
    Laravel Notification Facade → Custom FakeSmsChannel → Symfony Notifier → FakeSmsTransport
    
  • Alternative for Minimalism: If Symfony Notifier is overkill, consider lightweight alternatives like:
    • laravel-notification-testing (for unit tests).
    • Custom log-based mocking (e.g., extend Illuminate\Notifications\AnonymousNotifiable).
    • Environment-based routing in Laravel’s via() method:
      public function via($notifiable) {
          return config('app.env') === 'local' ? ['fake_sms'] : ['nexmo'];
      }
      

Migration Path

  1. Assess Current Stack:
    • Audit existing SMS notifications (e.g., Twilio, AWS SNS) and their integration points.
    • Check if Symfony Notifier or related components are already used.
  2. Pilot Integration:
    • Start with a single feature (e.g., OTP notifications) to test the bridge.
    • Use fakesms+logger first to avoid email routing complexities.
  3. Gradual Rollout:
    • Replace real SMS calls in development environments first.
    • Add feature flags to toggle fake vs. real SMS in staging.
  4. Fallback Strategy:
    • Ensure production uses real SMS providers with environment checks:
      if (app()->environment('local')) {
          // Use FakeSmsService
      } else {
          // Use Twilio/AWS SNS
      }
      

Compatibility

  • Laravel Version: Tested with Laravel 10+ (PHP 8.1+). Older versions may require Symfony 6.x compatibility.
  • Symfony Notifier: Ensure version alignment with Laravel’s dependencies (e.g., avoid Symfony 8.x if Laravel uses 6.x).
  • SMS Providers: Fake SMS does not replace real providers. Production must use separate configurations (e.g., NEXMO_KEY vs. FAKE_SMS_DSN).
  • Logging: For fakesms+logger, configure Laravel’s logging to exclude fake SMS logs from production channels:
    'channels' => [
        'fake_sms' => [
            'driver' => 'single',
            'path' => storage_path('logs/fake_sms.log'),
            'level' => 'debug',
        ],
    ],
    

Sequencing

  1. Phase 1: Setup
    • Install dependencies: symfony/notifier, symfony/fake-sms-notifier.
    • Configure .env with FAKE_SMS_DSN.
    • Create a Laravel service to bridge notifications (e.g., FakeSmsService).
  2. Phase 2: Testing
    • Verify fake SMS appears in logs/emails for development.
    • Test edge cases (e.g., long messages, special characters).
  3. Phase 3: Integration
    • Replace real SMS calls in feature branches.
    • Add CI/CD checks to validate fake SMS behavior.
  4. Phase 4: Production Readiness
    • Ensure environment-based routing (fake in dev, real in prod).
    • Document the dual-system configuration for on-call teams.

Operational Impact

Maintenance

  • Dependency Management: Symfony Notifier’s large dependency tree may require frequent updates to avoid conflicts. Use composer why-not to audit dependencies.
  • Abstraction Layer: The custom bridge between Laravel and Symfony Notifier will need maintenance if:
    • Symfony Notifier’s API changes (e.g., breaking changes in v8.0).
    • Laravel’s Notification system evolves (e.g., new channel contracts).
  • Configuration Drift: Risk of forgotten FAKE_SMS_DSN in production-like environments. Enforce checks:
    if (app()->environment('production') && env('FAKE_SMS_DSN')) {
        throw new \RuntimeException('Fake SMS enabled in production!');
    }
    

Support

  • Debugging Complexity: Issues may span Laravel, Symfony, and FakeSMS layers. Isolate problems by:
    • Checking Symfony Notifier logs first.
    • Verifying the DSN format (fakesms+email://...).
    • Testing with fakesms+logger to bypass email routing.
  • Stakeholder Training: Developers/QA must understand:
    • How to read fake SMS logs/emails.
    • When to switch between fake/real SMS.
    • How to **configure
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.
jayeshmepani/jpl-moshier-ephemeris-php
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