PHP API: "Class Client could not be loaded from Client.php, file does not exist"
Posted: Tue Mar 08, 2016 9:57 am
I'm trying the recommended PHP API:
The message from the var_dump is this error: "Class Client could not be loaded from Client.php, file does not exist (registered paths="phar:///var/www/project/PEAR2_Net_RouterOS-1.0.0b5.phar/PEAR2_Net_RouterOS-1.0.0b5/src") [PEAR2_Autoload-0.2.4]". What am I missing here?
Code: Select all
<?php
use PEAR2\Net\RouterOS;
require_once 'PEAR2_Net_RouterOS-1.0.0b5.phar';
try {
$client = new Client('192.168.100.1', 'admin', 'password', 8728);
echo 'Connected!';
$responses = $client->sendSync(new RouterOS\Request('/ip/arp/print'));
foreach ($responses as $response) {
if ($response->getType() === Response::TYPE_DATA) {
echo 'IP: ', $response->getProperty('address'),
' MAC: ', $response->getProperty('mac-address'),
"\n";
}
}
} catch (Exception $e) {
echo '<pre>';
var_dump($e);
echo '</pre>';
}