1. Go to this page and download the library: Download beziworld/laravel-unifi library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
Unifi::info()->applicationVersion; // "9.1.120"
Unifi::sites()->all(); // LazyCollection<Site>
Unifi::forSite('hotel2')->devices()->list(); // short name or UUID
foreach (Unifi::devices()->all() as $device) {
if (! $device->isOnline()) {
// alert
}
}
Unifi::devices()->statistics($deviceId)->cpuUtilizationPct;
Unifi::devices()->restart($deviceId);
Unifi::devices()->powerCyclePort($switchId, portIdx: 7); // reboot a PoE access point
Unifi::devices()->pending(); // devices waiting for adoption
Unifi::devices()->adopt('94:2a:6f:26:c6:ca');
Unifi::networks()->list()->items; // Network (name, management, vlanId, ...)
Unifi::networks()->wans(); // ['uuid' => 'Internet 1']
Unifi::wifi()->all(); // WifiBroadcast (SSIDs)
Unifi::wifi()->disable($broadcastId); // reads the definition and sends it back
Unifi::wifi()->update($broadcastId, $definition); // full definition, as in the official schema
// Any endpoint of the official API; {siteId} is replaced with the current site UUID
Unifi::request('GET', '/v1/sites/{siteId}/firewall/policies');
Unifi::request('POST', '/v1/sites/{siteId}/acl-rules', body: [...]);
// Any classic endpoint of the current site
Unifi::classic()->request('GET', 'stat/health');