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

Chikka Laravel Package

ridvanbaluyos/chikka

View on GitHub
Deep Wiki
Context7
## Getting Started
Install the package via Composer:
```bash
composer require vendor/sms-package

Publish the configuration file (if available) to customize API credentials:

php artisan vendor:publish --provider="Vendor\SmsPackage\SmsPackageServiceProvider"

Register the SMS service in config/services.php with your API credentials (e.g., SMS_API_KEY, SMS_API_SECRET).

First Use Case: Send a basic SMS via the facade or service container:

use Vendor\SmsPackage\Facades\Sms;

// Send a single SMS
Sms::send('+1234567890', 'Hello from Laravel!');

Check the documentation for API endpoint specifics (e.g., rate limits, character limits).


Implementation Patterns

Core Workflow

  1. Configuration: Store API credentials in .env (e.g., SMS_API_KEY=your_key_here). Override defaults in config/sms.php if needed.

  2. Sending SMS:

    • Facade: Use Sms::send($phone, $message) for simplicity.
    • Service Container: Bind the service in AppServiceProvider for dependency injection:
      $this->app->bind('sms', function ($app) {
          return new \Vendor\SmsPackage\SmsService($app['config']['sms']);
      });
      
    • Queues (Recommended for Production): Wrap SMS sending in a job to avoid timeouts:
      use Vendor\SmsPackage\Jobs\SendSms;
      
      SendSms::dispatch('+1234567890', 'Your OTP is 1234')->delay(now()->addSeconds(5));
      
  3. Response Handling: Check the response object for status:

    $response = Sms::send($phone, $message);
    if ($response->success()) {
        // Handle success
    } else {
        log::error('SMS failed: ' . $response->getError());
    }
    

Integration Tips

  • Validation: Validate phone numbers before sending (e.g., use vendor/sms-package/helpers if available).
  • Logging: Log all SMS attempts for debugging:
    \Log::channel('sms')->info('SMS sent to ' . $phone, ['message' => $message]);
    
  • Testing: Mock the SMS service in tests:
    $this->partialMock(Sms::class, function ($mock) {
        $mock->shouldReceive('send')->andReturn(new \Vendor\SmsPackage\Response(true));
    });
    

Gotchas and Tips

Pitfalls

  1. API Rate Limits: The package does not enforce rate limits by default. Monitor your API usage to avoid throttling. Workaround: Implement a throttle middleware or use a queue with delay.

  2. Character Limits: SMS messages are typically limited to 160 characters (or 70 for Unicode). Longer messages may be split or fail silently. Tip: Use Str::limit($message, 150) to enforce safe lengths.

  3. No Retry Mechanism: Failed SMS sends are not retried automatically. Implement exponential backoff in your job if reliability is critical.

  4. No Multi-Part SMS Support: Only single-part SMS is supported in v1.0. Plan for message truncation if sending longer texts.

Debugging

  • Enable Debug Mode: Set SMS_DEBUG=true in .env to log raw API responses.
  • Check HTTP Status Codes: The response object includes the HTTP status code. Use it to distinguish between:
    • 200 (Success)
    • 400 (Bad Request, e.g., invalid phone)
    • 429 (Too Many Requests)
    • 500 (Server Error)

Extension Points

  1. Custom Responses: Extend the Response class to add domain-specific logic:

    class CustomResponse extends \Vendor\SmsPackage\Response {
        public function isDeliveryReport() {
            return $this->data['status'] === 'DELIVERED';
        }
    }
    

    Bind your custom class in AppServiceProvider.

  2. Add New Features: The package is modular. Fork and extend the SmsService class to support:

    • OTP Generation: Add a generateOtp() method.
    • Template Messages: Support placeholders (e.g., Hello {name}).
    • Webhooks: Implement a registerWebhook method for delivery notifications.
  3. Support for Other APIs: The package may abstract the underlying SMS provider. Check the source for SmsService::send() to see how to add support for Twilio, AWS SNS, etc.

Configuration Quirks

  • Default Phone Format: The package may expect E.164 format (+1234567890). Normalize phone numbers before sending:
    $phone = '+'. ltrim($rawPhone, '+');
    
  • Environment-Specific Credentials: Use .env variables like SMS_API_KEY_STAGING and switch them via:
    config(['sms.api_key' => env('SMS_API_KEY_' . app()->environment())]);
    

NO_UPDATE_NEEDED would **not** apply here due to the new v1.0 release introducing core functionality. The above is the updated assessment.
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.
adachsoft/command-executor-lib
tagixo/document-builder
tagixo/page-builder
tagixo/mail-builder
tagixo/form-builder
primix/primix
tagixo/core
alesima/laravel-azure-service-bus
tomshaw/shopcart
likyly/laravel
darthsoup/shoppingcart
tdt/core
labyrinthe/connect-php
encore2/laravel-admin2
cboxdk/laravel-console-kit
shapecode/doctrine-dbal-datetimeutc
gilads-otiannoh254/inertia-protocol
dakiquang/laravel-oauth-refresh-lock
woda/laravel-worktrees
dalefranks/ramasite