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

Turbosms Soapgate Client Php Laravel Package

sunra/turbosms-soapgate-client-php

PHP client library to connect to TurboSMS.ua via its SOAP gateway. Create a Turbosms\Soap\Client with login, password, and sender ID to send SMS through the TurboSMS SOAP API.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation Add the package via Composer:

    composer require sunra/turbosms-soapgate-client-php
    
  2. Basic Initialization Import the client and initialize with your TurboSMS credentials:

    use Sunra\PhpSimple\SoapClient;
    
    $client = new SoapClient('https://soap.turbosms.ua/soapgate.asmx?WSDL', [
        'trace' => 1,
        'exceptions' => true,
        'login' => 'YOUR_TURBOSMS_LOGIN',
        'password' => 'YOUR_TURBOSMS_PASSWORD',
    ]);
    
  3. First Use Case: Sending an SMS Call the SendSMS method with required parameters:

    $response = $client->SendSMS([
        'Phone' => '380661234567',
        'Message' => 'Hello from Laravel!',
        'Sender' => 'YourBrand',
    ]);
    

Implementation Patterns

Common Workflows

  1. Sending Bulk SMS Loop through recipients and batch requests (avoid rate limits):

    $recipients = ['380661234567', '380661234568'];
    foreach ($recipients as $phone) {
        $client->SendSMS(['Phone' => $phone, 'Message' => 'Bulk message']);
    }
    
  2. Handling Responses Parse SOAP responses (e.g., check for errors):

    try {
        $response = $client->SendSMS([...]);
        if ($response->SendSMSResult === 'OK') {
            Log::info('SMS sent successfully');
        }
    } catch (\SoapFault $fault) {
        Log::error('SOAP Error: ' . $fault->getMessage());
    }
    
  3. Integration with Laravel Queues Dispatch a job for async SMS sending:

    // In a job class
    public function handle() {
        $client = new SoapClient(...);
        $client->SendSMS([...]);
    }
    
  4. Retrieving Balance Check remaining credits:

    $balance = $client->GetBalance();
    

Configuration Tips

  • Store credentials in Laravel’s .env:
    TURBOSMS_LOGIN=your_login
    TURBOSMS_PASSWORD=your_password
    
  • Use a service provider to centralize the client:
    // app/Providers/TurboSmsServiceProvider.php
    public function register() {
        $this->app->singleton('turbosms', function () {
            return new SoapClient('https://soap.turbosms.ua/soapgate.asmx?WSDL', [
                'login' => env('TURBOSMS_LOGIN'),
                'password' => env('TURBOSMS_PASSWORD'),
            ]);
        });
    }
    

Gotchas and Tips

Pitfalls

  1. SOAP Fault Handling

    • The package throws \SoapFault on errors. Always wrap calls in try-catch.
    • Example error: SOAP-ERROR: Encoding: Could not serialize parameters.
  2. Character Limits

    • TurboSMS enforces a 70-character limit per SMS. Split longer messages:
      $message = str_split('Your long message...', 70);
      foreach ($message as $part) {
          $client->SendSMS(['Phone' => $phone, 'Message' => $part]);
      }
      
  3. Rate Limits

    • Avoid rapid successive calls (e.g., >10 SMS/minute). Implement delays:
      sleep(1); // 1-second delay between requests
      
  4. Deprecated Methods

    • The package is unmaintained (last release: 2016). Test thoroughly—some methods may fail silently.

Debugging

  • Enable SOAP tracing for logs:
    $client = new SoapClient(..., ['trace' => 1]);
    $lastRequest = $client->__getLastRequest();
    $lastResponse = $client->__getLastResponse();
    
  • Check TurboSMS’s SOAP API docs for undocumented quirks (e.g., Sender format must match ^[A-Za-z0-9]{1,11}$).

Extension Points

  1. Custom Response Parsing Override the client to normalize responses:

    $response = $client->SendSMS([...]);
    $result = $response->SendSMSResult === 'OK' ? true : false;
    
  2. Retry Logic Implement exponential backoff for failed requests:

    $attempts = 0;
    while ($attempts < 3) {
        try {
            $client->SendSMS([...]);
            break;
        } catch (\SoapFault $e) {
            $attempts++;
            sleep(2 ** $attempts);
        }
    }
    
  3. Mocking for Tests Use PHP’s SoapClient mocking or a wrapper:

    // In tests
    $mock = $this->getMockBuilder('SoapClient')
        ->disableOriginalConstructor()
        ->onlyMethods(['SendSMS'])
        ->getMock();
    $mock->method('SendSMS')->willReturn(new stdClass());
    
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