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 Composer, this introduces architectural divergence and potential maintenance overhead.
  • Laravel Compatibility: Laravel’s Notification system relies on channels (e.g., MailChannel, NexmoChannel), whereas this package uses Symfony’s transport-based system. Bridging these requires custom abstraction layers, increasing complexity.
  • Use Case Alignment: Perfect for development/testing where SMS gateways are unnecessary. However, its lack of Laravel-native integration may limit adoption in Laravel-centric teams.
  • Extensibility: The package’s design (DSN-based configuration) is clean and flexible, but extending it for Laravel-specific needs (e.g., Laravel Events, Queues) would require custom development.

Integration Feasibility

  • Symfony Notifier as a Service Layer: If the team is open to adopting Symfony Notifier alongside Laravel, integration is straightforward via:
    • Configuring the DSN in .env (e.g., FAKE_SMS_DSN=fakesms+email://default?to=dev@example.com).
    • Dispatching SMS via Symfony Notifier’s API (e.g., $notifier->sendSms($phone, $message)).
  • Laravel Notifications Bridge: For pure Laravel, a custom channel driver would need to be built to translate Laravel’s Notification calls to Symfony Notifier. Example:
    // app/Channels/FakeSmsChannel.php
    use Symfony\Component\Notifier\Notifier;
    use Illuminate\Notifications\Notification;
    
    class FakeSmsChannel
    {
        public function __construct(private Notifier $notifier) {}
    
        public function send($notifiable, Notification $notification)
        {
            $this->notifier->sendSms(
                new \Symfony\Component\Notifier\Bridge\Sms\PhoneNumber($notifiable->phone),
                $notification->toSms($notifiable)
            );
        }
    }
    
  • Environment-Based Routing: Use Laravel’s via() method to dynamically switch between fake and real channels:
    public function via($notifiable)
    {
        return app()->environment('local')
            ? ['fakesms'] // Custom channel
            : ['nexmo'];   // Real provider
    }
    
  • Dependency Injection: Requires registering Symfony Notifier in Laravel’s service container, which may conflict with existing dependencies.

Technical Risk

  • Dependency Conflicts: Symfony Notifier (~50+ dependencies) may introduce version conflicts with Laravel’s ecosystem (e.g., Symfony Mailer, HTTP Client).
  • Laravel-Symfony Integration Gap: No native Laravel support means additional development effort to bridge the two systems. This could delay time-to-value.
  • PHP Version Constraints: Requires PHP ≥8.1 (Symfony 7+) and ≥8.4 for v8.0. Laravel’s current LTS (v10.x) supports PHP 8.1–8.3, so upgrading PHP may be necessary.
  • Testing Overhead: If the team relies on Laravel’s built-in testing tools (e.g., laravel-notification-testing), this package may duplicate functionality or require parallel maintenance.
  • Production Fallback: The package is dev-only; ensuring a seamless transition to real SMS providers in production requires clear configuration management.

Key Questions

  1. Is Symfony Notifier already in use? If yes, integration is trivial. If no, assess the cost of adopting it alongside Laravel.
  2. What’s the team’s tolerance for architectural complexity? Bridging Laravel and Symfony systems may require significant custom code.
  3. Do we need Laravel-native features? For example, support for Laravel’s Events, Queues, or Testing Helpers.
  4. How will fake SMS outputs (emails/logs) be managed? Ensure they don’t clutter existing Laravel logs or inboxes.
  5. What’s the migration path for existing SMS tests? If the team uses laravel-notification-testing or similar, evaluate overlap and redundancy.
  6. Will this package replace or complement existing mocking solutions? Avoid duplication of effort.
  7. How will this impact CI/CD pipelines? Ensure fake SMS outputs (e.g., logs) are ignored or routed appropriately in automated tests.

Integration Approach

Stack Fit

  • Symfony Notifier + Laravel: Best suited for teams already using Symfony components (e.g., Symfony Mailer, HTTP Client) or willing to adopt them. The package’s transport-based design aligns well with Symfony’s ecosystem but introduces friction in pure Laravel stacks.
  • Laravel Notifications: Requires a custom channel driver to translate Laravel’s Notification system to Symfony Notifier. This is feasible but non-trivial, adding maintenance overhead.
  • Alternative for Laravel: If the goal is pure Laravel integration, consider:
    • Laravel Notification Testing: Built-in tools like NotificationFake may suffice for basic mocking.
    • Custom Fake Channel: Develop a lightweight fake channel without Symfony Notifier (e.g., logs SMS to a dedicated file or database table).
  • Hybrid Approach: Use this package only for Symfony-based services within a Laravel monolith, keeping Laravel-specific SMS logic separate.

Migration Path

  1. Assess Current SMS Workflow:
    • Identify where SMS notifications are dispatched (e.g., Notification::send(), custom services).
    • Check if Symfony Notifier is already in use or if a new dependency is acceptable.
  2. Phase 1: Proof of Concept (PoC)
    • Integrate Symfony Notifier in a non-production environment.
    • Test the fakesms+email and fakesms+logger transports.
    • Validate that fake SMS outputs (emails/logs) meet debugging needs.
  3. Phase 2: Laravel Bridge (If Needed)
    • Develop a custom channel driver to connect Laravel Notifications to Symfony Notifier.
    • Example:
      // app/Providers/NotificationServiceProvider.php
      use Symfony\Component\Notifier\Notifier;
      use App\Channels\FakeSmsChannel;
      
      public function boot()
      {
          Notification::extend('fakesms', function ($app) {
              return new FakeSmsChannel($app->make(Notifier::class));
          });
      }
      
  4. Phase 3: Environment-Based Routing
    • Configure Laravel to use the fake channel in local/staging and real providers in production.
    • Example .env:
      FAKE_SMS_DSN=fakesms+email://default?to=dev@example.com&from=TestSMS
      SMS_DRIVER=fake  # or 'nexmo', 'aws', etc.
      
  5. Phase 4: Testing and Validation
    • Update existing SMS tests to use the new fake channel.
    • Ensure no regression in production SMS flows.
    • Monitor logs/emails for fake SMS outputs.

Compatibility

  • Symfony Notifier: Requires Symfony 6.4+ (for Laravel compatibility) or 7.0+. Check for dependency conflicts with Laravel’s Symfony components (e.g., Mailer, HTTP Client).
  • Laravel Version: Tested with Laravel 10.x (PHP 8.1–8.3). PHP 8.4 may be needed for Symfony 8.0.
  • SMS Providers: The package is agnostic to real providers (Twilio, AWS SNS, etc.), so production fallbacks can remain unchanged.
  • Logging: The fakesms+logger transport uses Symfony’s Logger, which may not integrate seamlessly with Laravel’s Monolog. Consider custom log channels or dedicated log files.

Sequencing

  1. Dependency Setup:
    • Add symfony/notifier and symfony/fake-sms-notifier to composer.json.
    • Resolve and test for version conflicts.
  2. Configuration:
    • Set FAKE_SMS_DSN in .env.
    • Configure Symfony Notifier in Laravel’s service container.
  3. Channel Integration:
    • Implement the fake SMS channel (if bridging Laravel Notifications).
    • Update via() methods in notifications to use the fake channel in dev.
  4. Testing:
    • Replace manual SMS testing with fake outputs (emails/logs).
    • Validate edge cases (e.g., character limits, encoding).
  5. Production Readiness:
    • Ensure real SMS providers are properly configured and switched in production.
    • Document the environment-based routing for future developers.

Operational Impact

Maintenance

  • Dependency Management:
    • Symfony Notifier’s large dependency tree may require frequent updates and conflict resolution.
    • Monitor for security patches in Symfony components.
  • Custom Code:
    • If a Laravel bridge is built, maintain it alongside Laravel’s core.
    • Document how fake SMS channels work for onboarding new developers.
  • **Configuration
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.
codraw/entity-migrator
codraw/doctrine-extra
codraw/aws-tool-kit
codraw/validator
codraw/workflow
codraw/open-api
codraw/cron-job
codraw/process
codraw/log
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony