skydiablo/reactphp-uisp-api-client
Composer 安装命令:
composer require skydiablo/reactphp-uisp-api-client
包简介
ReactPHP client for Ubiquiti UISP API
README 文档
README
A ReactPHP-based client library for the Ubiquiti UISP (formerly UNMS) API.
Installation
composer require skydiablo/reactphp-uisp-api-client
Features
- Asynchronous API client built on ReactPHP v3
- Domain-driven design approach with Dependency Injection support
- Support for various UISP API domains:
- Devices
- Networks
- Clients
- Billing
- Sites
- Type-safe API parameters using PHP Enums
- Comprehensive test suite with PHPUnit
Basic Usage
<?php require 'vendor/autoload.php'; use React\Http\Browser; use SkyDiablo\UispApiClient\Client\UispClient; use SkyDiablo\UispApiClient\Services\Devices\DevicesService; use SkyDiablo\UispApiClient\Services\Devices\Parameters\ListDevicesParameters; use SkyDiablo\UispApiClient\Services\Devices\Parameters\DeviceType; use SkyDiablo\UispApiClient\Services\Devices\Parameters\DeviceRole; use SkyDiablo\UispApiClient\Services\Sites\Parameters\ListSitesParameters; use SkyDiablo\UispApiClient\Services\Sites\SitesService; // Method 1: Manual creation (for Dependency Injection) $browser = new Browser(); // Optional $client = new UispClient( 'https://your-uisp-instance.example.com', 'your-api-key', $browser // Optional: You can omit this parameter ); // Create domain services $devicesService = new DevicesService($client); $sitesService = new SitesService($client); // Method 2: Using the factory method (for simpler usage) // $client = UispClient::create( // 'https://your-uisp-instance.example.com', // 'your-api-key' // ); // $devicesService = new DevicesService($client); // $sitesService = new SitesService($client); // Example: Get all devices $devicesService->list()->then( function ($devices) { // Handle devices var_dump($devices); }, function ($error) { // Handle error echo "Error: " . $error->getMessage() . PHP_EOL; } ); // Example: Filter devices by type and role $deviceParams = new ListDevicesParameters(); $deviceParams->setType([DeviceType::ROUTER, DeviceType::WIRELESS]) ->setRole([DeviceRole::CPE]); $devicesService->list($deviceParams)->then( function ($devices) { echo "Found " . count($devices) . " devices matching the criteria" . PHP_EOL; } ); // Example: List sites with parameter filtering // Get all sites $sitesService->list()->then( function ($sites) { echo "Total sites: " . count($sites) . PHP_EOL; } ); // Filter sites by type $siteParams = new ListSitesParameters(); $siteParams->setType('customer') ->setUcrmDetails(true); $sitesService->list($siteParams)->then( function ($sites) { echo "Customer sites with CRM details: " . count($sites) . PHP_EOL; } ); // Run the event loop (ReactPHP will automatically use the global Loop instance) \React\EventLoop\Loop::run();
Tests
Unit Tests
Run the unit tests:
./vendor/bin/phpunit
Integration Tests
The integration tests require a running UISP instance and valid API credentials. Before running the integration tests:
- Copy
phpunit.integration.xml.disttophpunit.integration.xml - Update the environment variables in
phpunit.integration.xmlwith your UISP API credentials:UISP_API_URL: The URL of your UISP instanceUISP_API_TOKEN: Your UISP API token
Then run the integration tests:
./vendor/bin/phpunit -c phpunit.integration.xml
Documentation
- API Reference - Detailed documentation of classes and methods
- Usage Guide - Examples and usage patterns
- Error Handling - Guide to handling errors and exceptions
- Dependency Injection - Using the library with DI frameworks
- Logging - Configuring and using logging
- Framework Integration - Integrating with Laravel, Symfony, and Slim
- ReactPHP Usage - Advanced usage with ReactPHP
- Contributing Guide - Guidelines for contributing to the project
- UISP API-Docs - Official UISP API documentation and reference
License
MIT
skydiablo/reactphp-uisp-api-client 适用场景与选型建议
skydiablo/reactphp-uisp-api-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 03 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 skydiablo/reactphp-uisp-api-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 skydiablo/reactphp-uisp-api-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 27
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-03-20