- A composer package for Mikrotik / Router OS API
- Originally from: http://wiki.mikrotik.com/wiki/API_PHP_class
###Composer
Incorperate the following to your composer.json
file
"repositories": [
{
"type": "git",
"name": "tnoc/routeros",
"url": "http://github.com/TNOC/routeros_api"
}
],
"require": {
"tnoc/routeros": "dev-master"
}
Then update your dependencies: php composer.phar update
Example index.php
<?php
require_once "vendor/autoload.php";
use \RouterOS;
$api = new RouterOS\Core();
if ($api->connect('111.111.111.111', 'LOGIN', 'PASSWORD')) {
$api->write('/interface/getall');
$READ = $api->read(false);
$ARRAY = $api->parse_response($READ);
print_r($ARRAY);
$api->disconnect();
}
###./bin/routeros-test.php
RouterOS Test is a script to test that a Mikrotik is accessable through API
Usage:
php ./bin/routeros-test.php --help
php ./bin/routeros-test.php -h 111.111.111.111 -u username
Examples are from http://wiki.mikrotik.com/wiki/API_PHP_class