erbitron/dialog-esms 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

erbitron/dialog-esms

Composer 安装命令:

composer require erbitron/dialog-esms

包简介

PHP and Laravel client for Dialog eSMS API Sri Lanka

README 文档

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.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-07-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固