erbitron/dialog-esms

PHP and Laravel client for Dialog eSMS API Sri Lanka

Maintainers

Package info

github.com/bandaranaike/dialog-esms

Documentation

pkg:composer/erbitron/dialog-esms

Transparency log

Statistics

Installs: 4

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

v1.0.1 2026-07-02 14:20 UTC

This package is auto-updated.

Last update: 2026-07-02 14:20:33 UTC


README

PHP 8.1+ client for the Dialog Axiata Sri Lanka eSMS API, published on Packagist and ready for Laravel or plain PHP projects.

Packagist Version Packagist Downloads CI

Source repository: https://github.com/bandaranaike/dialog-esms Packagist: https://packagist.org/packages/erbitron/dialog-esms Docs index: docs/README.md

Contents

Installation

Install from Packagist

composer require erbitron/dialog-esms

Local development with a path repository

If you are working on the package locally, add this to your application composer.json:

"repositories": [
  {
    "type": "path",
    "url": "../dialog-esms"
  }
]

Then install the package:

composer require erbitron/dialog-esms

Install directly from GitHub during development

If you want to install from the GitHub repository directly, add a VCS repository entry:

"repositories": [
  {
    "type": "vcs",
    "url": "https://github.com/bandaranaike/dialog-esms"
  }
]

Then require it normally:

composer require erbitron/dialog-esms

Notes

  • For normal projects, installing from Packagist is the recommended path.
  • Use the path or VCS repository entries only for local development or when you need an unpublished change.

Plain PHP usage

use Erbitron\DialogESMS\DialogESMSClient;

$client = new DialogESMSClient('your-api-key');

$response = $client->sendMessage(
    recipients: '94771234567',
    message: 'Hello from website',
    sourceAddress: 'YourBrand'
);

if ($response->successful()) {
    echo 'SMS sent';
} else {
    echo $response->message;
}

Laravel usage

The package is auto-discovered by Laravel.

use Erbitron\DialogESMS\DialogESMSClient;

class SmsController
{
    public function send(DialogESMSClient $sms)
    {
        $response = $sms->sendMessage(
            recipients: '94771234567',
            message: 'Your OTP is 123456',
            sourceAddress: 'YourBrand'
        );

        return $response->message;
    }
}

You can also use the facade:

use DialogESMS;

$response = DialogESMS::checkBalance();

Environment variables

DIALOG_ESMS_API_KEY=your-api-key
DIALOG_ESMS_CALLBACK_URL=https://your-site.com/dialog-esms/callback

Optional:

DIALOG_ESMS_BASE_URL=https://e-sms.dialog.lk/api/v1/message-via-url

Config publishing

Publish the Laravel config file:

php artisan vendor:publish --tag=dialog-esms-config

Send SMS example

use Erbitron\DialogESMS\DialogESMSClient;

$client = new DialogESMSClient('your-api-key');

$response = $client->sendMessage(
    recipients: '94771234567',
    message: 'Hello from website',
    sourceAddress: 'YourBrand'
);

if ($response->successful()) {
    echo 'SMS sent';
} else {
    echo $response->message;
}

Check balance example

use Erbitron\DialogESMS\DialogESMSClient;

$client = new DialogESMSClient('your-api-key');
$response = $client->checkBalance();

echo $response->message;
echo $response->balance ?? '';

Error handling example

use Erbitron\DialogESMS\DialogESMSClient;
use Erbitron\DialogESMS\Exceptions\DialogESMSException;

try {
    $client = new DialogESMSClient('your-api-key');
    $response = $client->sendMessage(
        recipients: '94771234567',
        message: 'Hello',
        sourceAddress: 'YourBrand'
    );
} catch (DialogESMSException $e) {
    report($e);
}

Contributing

See CONTRIBUTING.md for the contribution workflow and local checks.

Security

If you discover a security issue, do not open a public issue with exploit details. Please report it through GitHub Security Advisories or create a private security report for the repository if available.

Release

See RELEASE.md for the release checklist and Packagist publishing flow.

License

This package is released under the MIT license. See the LICENSE file in the repository.