1. Go to this page and download the library: Download epiecs/phpmiko 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/ */
epiecs / phpmiko example snippets
ce = new \Epiecs\PhpMiko\ConnectionHandler([
'device_type' => 'junos',
'hostname' => '192.168.0.1',
'username' => 'my_user',
'password' => 'mysafepassword',
]);
print_r($device->operation([
'show system uptime',
'show system alarms',
]));
/*
Array
(
[show system uptime] => fpc0:
--------------------------------------------------------------------------
Current time: 2018-11-02 02:30:18 CET
Time Source: LOCAL CLOCK
System booted: 2018-09-15 09:22:02 CEST (6w5d 18:08 ago)
Protocols started: 2018-09-15 09:24:40 CEST (6w5d 18:05 ago)
Last configured: 2018-10-14 06:47:11 CEST (2w4d 20:43 ago) by itdept
2:30AM up 47 days, 18:08, 3 users, load averages: 0.11, 0.11, 0.08
[show system alarms] => No alarms currently active
)
*/
print_r($device->configure([
'set interfaces ge-0/0/47 description "Test for documentation"',
'edit interfaces ge-0/0/46',
'set description "Sequential commands work"',
]));
/*
Array
(
[set interfaces ge-0/0/47 description "Test for documentation"] =>
[edit interfaces ge-0/0/46] =>
[set description "Sequential commands work"] =>
)
*/
ce = new \Epiecs\PhpMiko\ConnectionHandler([
'device_type' => 'junos',
'hostname' => '192.168.0.1',
'username' => 'username',
'password' => 'password',
'protocol' => 'ssh', //default is ssh
'port' => 22, //defaults to the protocol default if not set
'secret' => 'secret', //default is ''
'verbose' => false, //default is false
'raw' => false //default is false
]);