tomb1n0/unifiapi

There is no license information available for the latest version (0.1.1) of this package.

0.1.1 2021-03-24 20:01 UTC

README

This package was designed to make it easy to work with a Unifi controller.

Installation

Make sure you have composer installed, then run composer require tomb1n0/unifiapi from the root of your project.

Make sure to then include the composer autoload file in your code.

<?php
  
require_once('vendor/autoload.php');

// replace these with your own details.
define('UNIFI_URL', 'https://unifi.yourdomain.co.uk:8443');
define('UNIFI_SITE', 'Southampton');
define('UNIFI_USERNAME', 'admin');
define('UNIFI_PASSWORD', 'unifipassword');

// get an instance of the api
$api = new UnifiAPI\API(UNIFI_URL, UNIFI_SITE, UNIFI_USERNAME, UNIFI_PASSWORD);

// get a controller object
$controller = $api->controller();

Examples

Get controller health (number of APs online etc)

$health = $controller->health();

$wlan_health = $health[0];
$wan_health = $health[1];
$www_health = $health[2];
$lan_health = $health[3];
$vpn_health = $health[4];

echo 'Num Adopted APs: ' . $wlan_health['num_adopted'];

Fetching any unadopted WAPs

// get any unadopted WAPs
$devices = $controller->unadopted_devices();

// Adopt each of them
foreach ($devices as $device) {
    $device->adopt();
}