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

Sdk Laravel Package

esendex/sdk

PHP 8.3+ SDK for Esendex SMS messaging. Install via Composer and authenticate with your account to send SMS and retrieve inbox messages. Includes dispatch and inbox services, uses cURL, and supports autoloading via Composer or bundled loader.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Microservice/API Layer Fit: Ideal for Laravel applications requiring SMS functionality (e.g., notifications, 2FA, alerts). The SDK abstracts Esendex’s REST API, reducing boilerplate for HTTP requests, authentication, and response handling.
  • Domain-Driven Design (DDD) Alignment: Models (DispatchMessage, InboxMessage) align with DDD principles, enabling clean integration into Laravel’s service layer or repositories.
  • Event-Driven Potential: Can be extended to trigger Laravel events (e.g., SmsSent, SmsFailed) via SDK callbacks or post-send webhooks (Esendex supports this).

Integration Feasibility

  • Laravel Ecosystem Compatibility:
    • Service Providers: Can be bootstrapped as a Laravel service provider to centralize configuration (API keys, retries, logging).
    • Facades/Helpers: Wrap SDK methods in Laravel-specific helpers (e.g., Sms::send()) for consistency with existing codebase patterns.
    • Queue Integration: Leverage Laravel Queues to defer SMS sends (critical for scalability).
  • Database Sync: Supports storing message IDs/URIs in Laravel models (e.g., User table) for tracking or retries.

Technical Risk

  • Deprecation Risk: Last release in 2021 (3+ years stale). Assess:
    • Esendex API backward compatibility (check changelog).
    • PHP 8.3 requirement (Laravel 10+ supports this, but older Laravel versions may conflict).
  • Testing Gaps:
    • No Laravel-specific tests; manual validation needed for edge cases (e.g., rate limits, invalid numbers).
    • Mock Esendex API responses in unit tests (use Vcr or Mockery).
  • Security:
    • Hardcoded credentials in code violate Laravel’s best practices. Use .env + Laravel’s config/services.php.
    • No built-in request signing; rely on Esendex’s API keys (assume HTTPS).

Key Questions

  1. API Stability: Has Esendex deprecated any endpoints used by this SDK since 2021?
  2. Rate Limits: Does the SDK handle Esendex’s rate limits (e.g., retries, exponential backoff)?
  3. Webhooks: Can Laravel listen to Esendex webhooks (e.g., delivery reports) for async updates?
  4. Multi-Tenancy: How to scope SDK instances for multi-tenant Laravel apps (e.g., per-account API keys)?
  5. Monitoring: Does the SDK support logging (e.g., Monolog) or metrics (e.g., Prometheus) for observability?

Integration Approach

Stack Fit

  • Laravel Core:
    • Service Container: Bind SDK services (DispatchService, InboxService) as singletons with resolved credentials.
    • Events: Dispatch Laravel events after SDK calls (e.g., SmsSent with message metadata).
    • Validation: Use Laravel’s validator to sanitize phone numbers before SDK submission.
  • Queue System:
    • Wrap SDK calls in Laravel Jobs (e.g., SendSmsJob) for async processing.
    • Example:
      class SendSmsJob implements ShouldQueue {
          public function handle() {
              $service = app(Esendex\DispatchService::class);
              $result = $service->send($this->message);
              event(new SmsSent($result));
          }
      }
      
  • Testing:
    • Use Laravel’s MockHttp or HttpTestResponse to stub Esendex API calls in feature tests.
    • Example:
      $this->mockEsendexApi()
           ->shouldReceive('send')
           ->once()
           ->andReturn(new Esendex\Model\Result("123"));
      

Migration Path

  1. Phase 1: Proof of Concept (PoC)
    • Integrate SDK in a single Laravel controller (e.g., SmsController).
    • Test core flows: send SMS, fetch inbox, track status.
    • Validate against Esendex’s sandbox.
  2. Phase 2: Service Layer Abstraction
    • Create a SmsService facade wrapping SDK methods.
    • Example:
      class SmsService {
          public function __construct(private DispatchService $dispatch) {}
          public function send(string $to, string $message): string {
              $dispatchMsg = new \Esendex\Model\DispatchMessage(
                  config('services.esendex.originator'),
                  $to,
                  $message,
                  \Esendex\Model\Message::SmsType
              );
              return $this->dispatch->send($dispatchMsg)->id();
          }
      }
      
  3. Phase 3: Production Readiness
    • Add retries (use Laravel’s Retryable interface or spatie/laravel-queue-retries).
    • Implement logging (e.g., monolog/monolog for SDK responses).
    • Set up monitoring (e.g., track SmsSent event failures).

Compatibility

  • Laravel Versions:
    • Supported: Laravel 10+ (PHP 8.3+). For older versions, pin SDK to PHP 7.4+ branch if available.
    • Workarounds: Use Laravel 9’s PHP 8.1 support with SDK’s PHP 7.3+ branch (if backported).
  • PHP Extensions: Ensure ext-curl is enabled (Laravel’s default).
  • Esendex API: Confirm no breaking changes since 2021 (e.g., OAuth vs. basic auth).

Sequencing

  1. Prerequisites:
    • Set up Esendex account and test credentials.
    • Configure Laravel .env:
      ESENDEX_ACCOUNT=EX000000
      [email protected]
      ESENDEX_PASSWORD=secret
      ESENDEX_ORIGINATOR=YourApp
      
  2. Core Integration:
    • Install SDK via Composer.
    • Register service provider (EsendexServiceProvider) in config/app.php.
  3. Advanced Features:
    • Add queue jobs for async sends.
    • Implement webhook listeners (if using Esendex callbacks).
  4. Testing:
    • Unit tests for SmsService.
    • End-to-end tests with Laravel’s HTTP tests.

Operational Impact

Maintenance

  • Dependency Updates:
    • Monitor Esendex API changes; update SDK if major version bumps occur.
    • Pin SDK version in composer.json to avoid surprises (e.g., 3.0.0).
  • Credential Rotation:
    • Use Laravel’s config/services.php to externalize credentials:
      'esendex' => [
          'account' => env('ESENDEX_ACCOUNT'),
          'username' => env('ESENDEX_USERNAME'),
          'password' => env('ESENDEX_PASSWORD'),
      ],
      
    • Implement a rotate-esendex-credentials Artisan command.
  • Deprecation Plan:
    • If SDK is abandoned, migrate to Esendex’s official PHP SDK (if available) or a custom Guzzle-based client.

Support

  • Troubleshooting:
    • Log SDK responses (e.g., result->errors()) to debug failures.
    • Esendex’s API status page for outages.
  • Escalation Path:
    • Contact Esendex support for API issues ([email protected]).
    • Laravel community for integration issues (e.g., Stack Overflow, GitHub).
  • Documentation Gaps:
    • Create internal runbooks for:
      • Common errors (e.g., invalid numbers, rate limits).
      • SDK method reference (e.g., InboxService::latest() parameters).

Scaling

  • Performance:
    • Async Processing: Offload SMS sends to queues to avoid blocking HTTP requests.
    • Batch Operations: Use Esendex’s bulk API (if supported) for high-volume sends.
  • Rate Limits:
    • Implement exponential backoff for retries (Laravel’s retry helper or spatie/laravel-queue-retries).
    • Monitor Esendex’s rate limits and adjust queue concurrency.
  • Cost Optimization:
    • Cache frequent inbox checks (e.g., Esendex\InboxService::latest()).
    • Use Esendex’s number validation API to reduce failed sends.

Failure Modes

Failure Scenario Impact Mitigation
Esend
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.
skyraptor/chatter
edlugz/sasapay
abbasudo/artisan-route
mirvan/ippanel
ignibyte/aic-framework
glavweb/data-schema-bundle
glavweb/datagrid-bundle
tacticmedia/scim-server
uni-method/frame
neika-ai/sdk
adachsoft/php-code-style
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
adachsoft/api-version-bundle
cgv/localized-resource