akramghaleb/laravel-grandstream

Laravel SDK for Grandstream Devices

Fund package maintenance!
Akram Ghaleb

Installs: 2

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/akramghaleb/laravel-grandstream

v1.0.1 2025-10-18 10:11 UTC

This package is auto-updated.

Last update: 2025-10-18 11:01:11 UTC


README

Latest Version on Packagist Total Downloads

๐Ÿ“ฆ Overview

Laravel Grandstream is a clean SDK for integrating Laravel apps with Grandstream UCM PBX devices.
It simplifies REST API communication, including:

  • Challenge โ†’ Token โ†’ Cookie authentication flow
  • Cached login cookies per user/session
  • Unified API request handling with auto-retry on cookie expiration
  • Easy integration into Filament dashboards or CRM systems

Ideal for real-time call monitoring, extension management, or PBX-based CRM dashboards.

๐Ÿ“– Official API Reference

The complete Grandstream HTTPS API documentation is available here:
๐Ÿ‘‰ Grandstream UCM6xxx HTTPS API Guide (PDF)

It includes:

  • Authentication flow (challenge โ†’ login)
  • Voice & call control endpoints (listBridgedChannels, Hangup, CallTransfer, etc.)
  • CDR & Recording APIs (cdrapi, recapi)
  • Error codes and result structures

This Laravel package aligns with the same API structure and request schema described in that official document.

โš™๏ธ Installation

Install the package via Composer:

composer require akramghaleb/laravel-grandstream

Then publish the configuration file:

php artisan vendor:publish --tag="laravel-grandstream-config"

๐Ÿ”ง Configuration

A config/grandstream.php file will be created.
Add your device credentials to .env:

UCM_BASE=https://your-ucm-ip
UCM_API_USER=apiuser
UCM_API_PASS=apipassword
UCM_API_VER=1.2
UCM_COOKIE_TTL=9
GRANDSTREAM_WEBHOOK_USER=admin
GRANDSTREAM_WEBHOOK_PASS=password

๐Ÿš€ Usage

Use the Facade for simple calls:

use AkramGhaleb\LaravelGrandstream\Facades\Grandstream;

// Example: List extensions
$response = Grandstream::getData('listAccount', [
            'options' => 'extension,account_type,fullname,status,addr',
            'page' => 1, 'sidx' => 'extension', 'sord' => 'asc',
        ]);

// Example: Fetch call records (CDR)
$cdr = Grandstream::getData('cdrapi', ["format":"json"]);

The package automatically retries failed requests when cookies expire (-6, -8, -37).

๐Ÿงฉ Example Response

{
    "status": 0,
    "response": {
        "total": 125,
        "cdr": [
            {
            "call_time": "2025-10-18 09:14:23",
            "src": "1001",
            "dst": "1002",
            "duration": "00:00:12",
            "disposition": "ANSWERED"
            }
        ]
    }
}

๐Ÿงฑ Advanced Usage

Inject it directly instead of using the Facade:

use AkramGhaleb\LaravelGrandstream\Grandstream;

class CallController
{
    public function index()
    {
        $calls = Grandstream::getData('listUnBridgedChannels');
        return response()->json($calls);
    }
}

๐Ÿงช Testing

composer test

๐Ÿ“ Changelog

See CHANGELOG for details.

๐Ÿค Contributing

Contributions are welcome!
Please read CONTRIBUTING.md before submitting a PR.

๐Ÿ›ก๏ธ Security

For security vulnerabilities, please review our security policy.

๐Ÿ‘จโ€๐Ÿ’ป Credits

๐Ÿ“„ License

This project is open-source software licensed under the MIT License.
See LICENSE for more information.

๐ŸŒ Support

If you find this package useful, please โญ it on GitHub.
You can also support by sharing feedback, contributing, or improving documentation.