PHPackages                             global-cloud-media/fitsms - 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. global-cloud-media/fitsms

ActiveLibrary

global-cloud-media/fitsms
=========================

Official PHP SDK for FitSMS.lk Gateway

v1.0.0(1mo ago)01↑2900%MITPHP

Since Mar 28Pushed 1mo agoCompare

[ Source](https://github.com/Global-Cloud-Media-Pvt-Ltd/fitsms-php-sdk)[ Packagist](https://packagist.org/packages/global-cloud-media/fitsms)[ RSS](/packages/global-cloud-media-fitsms/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

FitSMS PHP SDK (v4)
===================

[](#fitsms-php-sdk-v4)

The official PHP SDK for the [FitSMS.lk](https://fitsms.lk) gateway, maintained by Global Cloud Media. This package provides a seamless way to integrate SMS capabilities into PHP and Laravel applications using the FitSMS v4 API.

---

🚀 Features
----------

[](#-features)

- **Auto-Formatting**: Converts Sri Lankan numbers into `947XXXXXXXX` format.
- **v4 Support**: Fully compatible with FitSMS v4 REST API.
- **Guzzle Powered**: Reliable HTTP requests using Guzzle.
- **Robust Error Handling**: Extracts meaningful API error messages.

---

📦 Installation
--------------

[](#-installation)

Install via Composer:

```
composer require global-cloud-media/fitsms
```

---

⚡ Quick Start
-------------

[](#-quick-start)

### 1. Initialize the Client

[](#1-initialize-the-client)

```
use GlobalCloudMedia\FitSMS\FitSMS;

$apiToken = 'YOUR_V4_API_TOKEN';
$senderId = 'GlobalCloud';

$sms = new FitSMS($apiToken, $senderId);
```

---

### 2. Send an SMS

[](#2-send-an-sms)

```
try {
    $response = $sms->send('0761234567', 'Hello from Global Cloud Media!');

    if ($response['status'] === 'success') {
        echo "Message Sent! RUID: " . $response['data']['ruid'];
    }
} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
}
```

---

### 3. Check Account Balance

[](#3-check-account-balance)

```
$balance = $sms->getBalance();
echo "Remaining Units: " . $balance['data']['sms_unit'];
```

---

📖 API Reference
---------------

[](#-api-reference)

MethodParametersDescriptionsend()recipient(s), messageSend SMSgetBalance()noneGet SMS balancegetStatus()ruid, recipientCheck delivery status---

⚙️ Advanced Usage
-----------------

[](#️-advanced-usage)

### Manual Status Reconciliation

[](#manual-status-reconciliation)

```
$status = $sms->getStatus('REF123456', '0761234567');
print_r($status);
```

---

### 🇱🇰 Sri Lankan Number Formatting

[](#-sri-lankan-number-formatting)

The SDK automatically formats numbers:

```
0761234567   → 94761234567
761234567    → 94761234567
+94761234567 → 94761234567

```

---

🔔 Webhook Integration (Recommended)
-----------------------------------

[](#-webhook-integration-recommended)

FitSMS v4 primarily uses webhooks for delivery updates.

### Sample Webhook Payload

[](#sample-webhook-payload)

```
{
    "status": "success",
    "data": {
        "to": "94770000000",
        "from": "MyBrand",
        "message": "Test",
        "sms_type": "plain",
        "sms_count": 1,
        "cost": 1.25,
        "send_by": "api",
        "ruid": "fe424939fc3c4b6dbcc876994517d712",
        "received_at": "2025-09-05T23:24:22+05:30",
        "expired_at": "2025-09-05T23:25:22+05:30"
    }
}
```

### Example Laravel Controller

[](#example-laravel-controller)

```
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use App\Models\SmsLog; // Assuming you have an SmsLog model

class FitSmsWebhookController extends Controller
{
    /**
     * Handle the incoming DLR from FitSMS v4

       NOTE: Since FitSMS is an external service, it cannot provide a Laravel CSRF token
     */

    public function handle(Request $request)
    {
        // 1. Log the raw data for debugging (helpful for your dev logs)
        Log::channel('sms')->info('FitSMS Webhook Received', $request->all());

        // 2. Extract key data from the 'data' nesting or root
        // Note: Check if FitSMS sends the 'data' wrapper in the webhook
        // or just the raw fields. Most v4 webhooks are flat.
        $ruid = $request->input('data.ruid') ?? $request->input('ruid');
        $status = $request->input('data.status') ?? $request->input('status');

        if (!$ruid) {
            return response()->json(['error' => 'RUID missing'], 400);
        }

        // 3. Update your database
        $sms = SmsLog::where('ruid', $ruid)->first();

        if ($sms) {
            $sms->update([
                'delivery_status' => strtolower($status),
                'updated_at' => now(),
            ]);

            return response()->json(['status' => 'success', 'message' => 'Record updated']);
        }

        // Return 200 even if record not found to stop FitSMS from retrying
        return response()->json(['status' => 'not_found'], 200);
    }
}
```

---

🛡 Best Practices
----------------

[](#-best-practices)

- Always store `ruid` for tracking
- Use webhooks instead of polling
- Implement retry logic for failed sends
- Log all webhook events for audit/debugging

---

📄 License
---------

[](#-license)

This project is licensed under the MIT License.

---

🤝 Contributing
--------------

[](#-contributing)

Contributions, issues, and feature requests are welcome!

---

👨‍💻 Maintainer
--------------

[](#‍-maintainer)

Maintained by [Global Cloud Media (pvt) Ltd.](https://globalcloudmedia.lk)

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance90

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

46d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3bf9b0afe9f2157a7221b8f09fbc16c29e8a7e12bdacfddcdb0e6c2e12ccc6b5?d=identicon)[danuja-dilanka](/maintainers/danuja-dilanka)

---

Top Contributors

[![danuja-dilanka](https://avatars.githubusercontent.com/u/27912184?v=4)](https://github.com/danuja-dilanka "danuja-dilanka (2 commits)")

---

Tags

fitsmsv4

### Embed Badge

![Health badge](/badges/global-cloud-media-fitsms/health.svg)

```
[![Health](https://phpackages.com/badges/global-cloud-media-fitsms/health.svg)](https://phpackages.com/packages/global-cloud-media-fitsms)
```

###  Alternatives

[neuron-core/neuron-ai

The PHP Agentic Framework.

1.8k245.3k21](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
