PHPackages                             sureshhemal/laravel-sms-sri-lanka - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. sureshhemal/laravel-sms-sri-lanka

ActiveLibrary

sureshhemal/laravel-sms-sri-lanka
=================================

A Laravel package for sending SMS through Sri Lankan providers (Hutch, with more providers coming soon)

1.0.8(10mo ago)24.9k↓50%MITPHPPHP ^8.1CI passing

Since Jul 6Pushed 10mo agoCompare

[ Source](https://github.com/sureshhemal/laravel-sms-sri-lanka)[ Packagist](https://packagist.org/packages/sureshhemal/laravel-sms-sri-lanka)[ RSS](/packages/sureshhemal-laravel-sms-sri-lanka/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (8)Versions (8)Used By (0)

Laravel SMS Sri Lanka
=====================

[](#laravel-sms-sri-lanka)

A Laravel package for sending SMS through Sri Lankan providers with seamless Laravel notifications integration, built with SOLID principles and clean architecture.

Features
--------

[](#features)

- ✅ **Sri Lankan SMS Provider**: Hutch (more providers coming soon)
- ✅ **Laravel Notifications**: Seamless integration with Laravel's notification system
- ✅ **SOLID Architecture**: Clean, maintainable, and extensible code
- ✅ **Provider Agnostic**: Easy to switch between providers
- ✅ **Configuration Driven**: Simple configuration management
- ✅ **Type Safe**: Full PHP 8.1+ type safety
- ✅ **Bulk SMS Support**: Send to multiple recipients efficiently
- ✅ **Custom Exceptions**: Granular error handling for better debugging
- ✅ **Modern Testing**: Comprehensive test suite with PHPUnit 10+ attributes

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require sureshhemal/laravel-sms-sri-lanka
```

The package will automatically register its service provider.

Configuration
-------------

[](#configuration)

Publish the configuration file:

```
php artisan vendor:publish --provider="Sureshhemal\SmsSriLanka\Providers\SmsServiceProvider"
```

This will create `config/sms-sri-lanka.php` in your config folder.

Environment Variables
---------------------

[](#environment-variables)

Add these to your `.env` file:

```
# SMS Provider
SMS_PROVIDER=hutch

# Hutch SMS Configuration
HUTCH_SMS_BASE_URL=https://bsms.hutch.lk/api
HUTCH_SMS_USERNAME=your_api_username
HUTCH_SMS_PASSWORD=your_api_password
HUTCH_SMS_DEFAULT_MASK=YourApp

# Hutch SMS Default Options
HUTCH_SMS_DELIVERY_REPORT_REQUEST=true
HUTCH_SMS_DEFAULT_CAMPAIGN_NAME=Laravel SMS
```

**Important**:

- The `HUTCH_SMS_USERNAME` must be an **API user account**, not a regular web user account. If you don't have API access, you must contact your Hutch agent to gain API access to your account.
- The `HUTCH_SMS_DEFAULT_MASK` refers to the "From" field in the Hutch SMS UI dropdown. You must contact your Hutch agent to get approved masks for your account.

Architecture Overview
---------------------

[](#architecture-overview)

The package follows SOLID principles and clean architecture:

```
src/
├── Contracts/                    # Interface definitions
│   ├── SmsServiceContract.php
│   ├── SmsAuthenticatorContract.php
│   ├── SmsConfigurationValidator.php
│   ├── SmsPayloadBuilder.php
│   ├── SmsHttpClient.php
│   ├── ReceivesSmsNotifications.php
│   └── SendsSmsNotification.php
├── Exceptions/                   # Custom exception classes
│   ├── SmsException.php
│   ├── SmsConfigurationException.php
│   ├── SmsSendException.php
│   └── SmsProviderException.php
├── Notifications/                # Laravel notification integration
│   ├── SmsNotification.php
│   └── Channels/SmsChannel.php
└── Providers/                    # Provider implementations
    ├── SmsServiceProvider.php
    └── Hutch/
        ├── HutchSmsService.php
        ├── HutchSmsAuthenticator.php
        ├── HutchConfigurationValidator.php
        ├── HutchPayloadBuilder.php
        └── HutchHttpClient.php

```

Usage
-----

[](#usage)

### 1. Setting Up Your Models

[](#1-setting-up-your-models)

Your models that can receive SMS notifications must implement the `ReceivesSmsNotifications` contract:

```
