shanemcc / phprouter
PHP Scripts for interacting with network devices
Installs: 1 033
Dependents: 0
Suggesters: 0
Security: 0
Stars: 9
Watchers: 4
Forks: 6
Open Issues: 6
Type:project
Requires
- php: >=7.2
This package is auto-updated.
Last update: 2024-10-15 13:43:52 UTC
README
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.
Supported Devices
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
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.
Debian / Ubuntu
apt-get install libssh2-php
Redhat / CentOS
yum install php-pecl-ssh2
Other
pecl install ssh2
Comments, Bugs, Feature Requests etc.
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 shanemcc@gmail.com