shanemcc/phprouter

用于与网络设备交互的PHP脚本

dev-master 2024-08-15 13:23 UTC

This package is auto-updated.

Last update: 2024-09-15 13:31:25 UTC


README

提供了一组库,允许通过PHP从/向多种网络设备读写数据,以帮助自动化。

最初,它仅设计用于从路由器脚本中读取数据,但后来扩展到支持其他设备类型和使用场景。

支持的设备

目前,支持限于我能访问的设备。如果您需要支持未提供的设备,请随时提交pull-request,或提供该设备的访问权限。(在大多数情况下,只读访问应该足够。)

使用方法

使用很简单,将仓库克隆到子文件夹中,运行git submodule update --init以拉取子模块,然后include('phprouter/PHPRouter.php');并开始使用。

示例用法

<?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;
?>

更深入的示例用法文档可在维基上找到

某些路由器类型有辅助函数(例如,我需要的那些!),例如ArborOS有saveConfig($logMessage)hasPendingConfig(),而IOS/IOSXR设备有getPrefixList($name, $type)

如果您使用基于ssh的路由器,则需要php的ssh2模块

Debian / Ubuntu

apt-get install libssh2-php

Redhat / CentOS

yum install php-pecl-ssh2

其他

pecl install ssh2

评论、错误、功能请求等。

请在github上的问题跟踪器中提出错误和功能请求。我很乐意通过github接收代码pull请求。

评论可以通过shanemcc@gmail.com发送。