Ray Patrick Soucy

Cisco for PHP

Release 1.0.7

This PHP class provides connectivity to Cisco switches and routers.  It was written out of necessity (because I refuse to use Perl) and has become the foundation for many of my operational systems.  In hopes that it will be useful for others, I've made it available here under the GNU General Public License.

Download or View Source

API Reference Documentation

This Cisco PHP class uses Telnet to connect to IOS-powered devices.  While many prefer to use pure SNMP for device management, I've found that for many operations SNMP is too costly in terms of CPU load on the device, and too slow for time-sensitive applications.  As a result, this class does a lot of text parsing.

I try to test this class against the following Cisco devices: Catalyst 2960, 3560, and 3750 series switches, Catalyst XL-series switches (3500-XL, etc.), 3550 series switches, 6500 series switches and routers, 7200 series routers, 7600 series routing switches, 1800, 2800, and 3800 series routers, and legacy routers like the 1720 and 3600.  Though my primary focus is the 3560 and 3750 series switch.

For most operations, data is returned in an associative array. When an operation returns several pieces of data, it returns an array of associative arrays (2-dimensional array) making it easy to manipulate the data in your application.

Example:

1
2
3
4
5
6
7
8
9
10
11
12
<?php

    
require 'Cisco.php';
    
$cisco = new Cisco('switch.net.example.com''password''username');

    
$cisco->connect();
    
$data $cisco->showMacAddressTable();
    
$cisco->close();

    
print_r($data);

?>

Cisco SSH for PHP

For those interested in an SSH version of this class, I have been working on an implimentation that makes use of phpseclib.

The following is an archive of the pre-release cisco_ssh class with a modified phpseclib (several fixes have been made to phpseclib that are not included in the current release).

Download Cisco SSH for PHP