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
Requires
- php: ^8.3
- illuminate/contracts: ^11.0||^12.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^10.0.0||^9.0.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- spatie/laravel-ray: ^1.35
README
๐ฆ 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.