Browse Source

Usage of legacy methods removed from all examples

pull/40/head
Paul Rock 6 years ago
parent
commit
fee89f30ee
  1. 2
      examples/bridge_hosts.php
  2. 6
      examples/different_queries.php
  3. 23
      examples/export.php
  4. 2
      examples/interface_print.php
  5. 2
      examples/ip_address_print.php
  6. 2
      examples/ip_filrewall_address-list_print.php
  7. 2
      examples/queue_simple_print.php
  8. 2
      examples/queue_simple_print_v2.php
  9. 4
      examples/queue_simple_write.php
  10. 2
      examples/system_package_print.php
  11. 6
      examples/vlans_bridge.php
  12. 6
      examples/vlans_bridge_v2.php
  13. 6
      examples/vlans_bridge_v3.php

2
examples/bridge_hosts.php

@ -22,5 +22,5 @@ $client = new Client($config);
$query = new Query('/interface/bridge/host/print');
// Send query to RouterOS
$response = $client->write($query)->read();
$response = $client->query($query)->read();
print_r($response);

6
examples/different_queries.php

@ -14,12 +14,12 @@ $client = new Client([
]);
for ($i = 0; $i < 10; $i++) {
$response = $client->wr('/ip/address/print');
$response = $client->qr('/ip/address/print');
print_r($response);
$response = $client->wr('/ip/arp/print');
$response = $client->qr('/ip/arp/print');
print_r($response);
$response = $client->wr('/interface/print');
$response = $client->qr('/interface/print');
print_r($response);
}

23
examples/export.php

@ -20,5 +20,26 @@ $client = new Client($config);
// Execute export command via ssh
$response = $client->export();
dump($response);
print_r($response);
/*
// In results you will see something like this
# jun/28/2020 16:31:21 by RouterOS 6.47
# software id =
#
#
#
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
/ip dhcp-client
add disabled=no interface=ether1
*/
// But here is another example
$query = new Query('/export');
// Execute export command via ssh but in style of library
$response = $client->query($query)->read();
dump($response);

2
examples/interface_print.php

@ -21,7 +21,7 @@ $client = new Client($config);
$query = new Query('/interface/getall');
// Send query to RouterOS
$request = $client->write($query);
$request = $client->query($query);
// Read answer from RouterOS
$response = $client->read();

2
examples/ip_address_print.php

@ -18,5 +18,5 @@ $client = new Client([
$query = new Query('/ip/address/print');
// Send query to RouterOS
$response = $client->write($query)->read();
$response = $client->query($query)->read();
print_r($response);

2
examples/ip_filrewall_address-list_print.php

@ -14,7 +14,7 @@ $client = new Client([
]);
// Send query to RouterOS and parse response
$response = $client->write('/ip/firewall/address-list/print')->read();
$response = $client->query('/ip/firewall/address-list/print')->read();
// You could treat response as an array except using array_* function

2
examples/queue_simple_print.php

@ -25,6 +25,6 @@ $ips = [
foreach ($ips as $ip) {
$query = new Query('/queue/simple/print', ['?target=' . $ip . '/32']);
$response = $client->wr($query);
$response = $client->qr($query);
print_r($response);
}

2
examples/queue_simple_print_v2.php

@ -24,7 +24,7 @@ $ips = [
];
foreach ($ips as $ip) {
$response = $client->wr([
$response = $client->qr([
'/queue/simple/print',
'?target=' . $ip . '/32'
]);

4
examples/queue_simple_write.php

@ -12,8 +12,8 @@ $client = new Client([
'pass' => 'admin'
]);
$out = $client->write(['/queue/simple/add', '=name=test'])->read();
$out = $client->query(['/queue/simple/add', '=name=test'])->read();
print_r($out);
$out = $client->write(['/queue/simple/add', '=name=test'])->read();
$out = $client->query(['/queue/simple/add', '=name=test'])->read();
print_r($out);

2
examples/system_package_print.php

@ -21,7 +21,7 @@ $client = new Client($config);
$query = new Query('/system/package/print');
// Send query to RouterOS
$request = $client->write($query);
$request = $client->query($query);
// Read answer from RouterOS
$response = $client->read();

6
examples/vlans_bridge.php

@ -35,14 +35,14 @@ foreach ($vlans as $vlanId => $ports) {
// Add bridges
$query = new Query('/interface/bridge/add');
$query->add("=name=vlan$vlanId-bridge")->add('vlan-filtering=no');
$response = $client->write($query)->read();
$response = $client->query($query)->read();
print_r($response);
// Add ports to bridge
foreach ($ports as $port) {
$bridgePort = new Query('/interface/bridge/port/add');
$bridgePort->add("=bridge=vlan$vlanId-bridge")->add("=pvid=$vlanId")->add("=interface=ether$port");
$response = $client->write($bridgePort)->read();
$response = $client->query($bridgePort)->read();
print_r($response);
}
@ -50,7 +50,7 @@ foreach ($vlans as $vlanId => $ports) {
foreach ($ports as $port) {
$vlan = new Query('/interface/bridge/vlan/add');
$vlan->add("=bridge=vlan$vlanId-bridge")->add("=untagged=ether$port")->add("=vlan-ids=$vlanId");
$response = $client->write($vlan)->read(false);
$response = $client->query($vlan)->read(false);
print_r($response);
}

6
examples/vlans_bridge_v2.php

@ -34,7 +34,7 @@ foreach ($vlans as $vlanId => $ports) {
'vlan-filtering=no'
]);
$response = $client->wr($query);
$response = $client->qr($query);
print_r($response);
// Add ports to bridge
@ -45,7 +45,7 @@ foreach ($vlans as $vlanId => $ports) {
"=interface=ether$port"
]);
$response = $client->wr($bridgePort);
$response = $client->qr($bridgePort);
print_r($response);
}
@ -57,7 +57,7 @@ foreach ($vlans as $vlanId => $ports) {
"=vlan-ids=$vlanId"
]);
$response = $client->wr($vlan);
$response = $client->qr($vlan);
print_r($response);
}

6
examples/vlans_bridge_v3.php

@ -28,7 +28,7 @@ $vlans = [
foreach ($vlans as $vlanId => $ports) {
// Add bridges
$response = $client->wr([
$response = $client->qr([
'/interface/bridge/add',
"=name=vlan$vlanId-bridge",
'vlan-filtering=no'
@ -37,7 +37,7 @@ foreach ($vlans as $vlanId => $ports) {
// Add ports to bridge
foreach ($ports as $port) {
$response = $client->wr([
$response = $client->qr([
'/interface/bridge/port/add',
"=bridge=vlan$vlanId-bridge",
"=pvid=$vlanId",
@ -48,7 +48,7 @@ foreach ($vlans as $vlanId => $ports) {
// Add untagged ports to bridge with tagging
foreach ($ports as $port) {
$response = $client->wr([
$response = $client->qr([
'/interface/bridge/vlan/add',
"=bridge=vlan$vlanId-bridge",
"=untagged=ether$port",

Loading…
Cancel
Save