Provides a library designed to allow reading/writing data to/from multiple types of network-device via PHP to aid in automation.
It was originally designed just for reading data from routers in scripts but evolved to support other device types and usages.
Device Type | Telnet? | SSH? |
---|---|---|
HP Procurve | ✅ | ✅ |
Cisco IOS | ✅ | ✅ |
Cisco IOSXR | ✅ | ✅ |
ArborOS | ❌ | ✅ |
APC PDU | ✅ | ❌ |
Currently, support is limited to what I have access to. If you want support for something that isn't, then please feel free to submit a pull-request, or provide access to the device in question. (Read-Only should be sufficient in most cases.)
Usage is simple, clone the repo into a subfolder, run git submodule update --init
to pull in the submodules and then include('phprouter/PHPRouter.php');
and begin using.
Example usage:
<?php
use ShaneMcC\PhpRouter\Implementations\CiscoRouter;
$router = new CiscoRouter('192.168.0.1', 'admin', 'password');
$router->connect();
$router->enable('enable');
$config = $router->exec('show run');
$router->disconnect();
echo $config;
?>
Further more in-depth example usage is documented on the wiki
Some of the router types have helper functions (ie, the ones I've needed!), eg ArborOS has saveConfig($logMessage)
and hasPendingConfig()
, and IOS/IOSXR devices have getPrefixList($name, $type)
If you are using ssh-based routers, you will need the ssh2 module for php.
apt-get install libssh2-php
yum install php-pecl-ssh2
pecl install ssh2
Bugs and Feature Requests should be raised on the issue tracker on github. I'm happy to recieve code pull requests via github.
Comments can be emailed to [email protected]