Download the PHP package marbocub/network-equipment without Composer
On this page you can find all versions of the php package marbocub/network-equipment. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package network-equipment
marbocub/network-equipment
A telnet client with response parser for network equipment written in PHP.
This library provide two features.
- Telnet client, that extends graze/telnet-client to provide waitForPrompt(), login(), enable(), configure() and several presets for network equipment
- The parser, that converts a supported Cisco IOS command response to the array
The parser is implemented as the integrated with telnet client and as the standalone library. If you want to use your own telnet/SSH client library, you can use the parser as standalone library.
Supported network equipment
Supported network equipment by the parser and the telnet client are:
- Cisco IOS
- Cisco IOS-XE
Telnet client may work with targeted are:
- Juniper JUNOS (with custom prompt setting)
- Linux and other UNIX like platforms (with custom prompt setting)
- Alaxala network switch
- Extreme XOS, HP Procurve, DLink and other intelligent network switch
Supported Cisco IOS commands by the parser
- show interface status
- show interface counters
- show mac address-table
- show lldp neighbors
- show ip interface brief
- show arp
Getting Started
Installing
Via Composer
Quick start example for telnet client
The following example login to a Cisco IOS switch to get and display the interface status:
Quick start example for standalone parser library
The following example parse the "show int status" command response getted from a Cisco IOS switch:
The result of examples
The result of both examples is:
Usage for Telnet Client
Instantiating a client
To instantiation a client, use the TelnetClient::factory() that return a TelnetClient instance:
Connect and Login to the network equipment
To login a network equipment, use the connect() method to create a socket first and then use the login() method:
Note: The difference of connect() between this library and the graze/telnet-client is the preset prompts for Cisco IOS.
Execute command and parse the response
Once connected, the execute() method can be used to write command to the socket and receive the response:
Note: Must be execute "terminal length 0" first for Cisco IOS.
Note: getResponseArray() calls the parser internally. Only works well with supported Cisco IOS command executed.
Turn on privileged mode for Cisco IOS
To enable privileged mode for Cisco IOS, the enable() method can be used:
Batch execute Cisco IOS configure commands (privileged mode must be turned on)
To configure Cisco IOS, the configure() method can be used:
Note: The first argument of the configure() is an array listing the commands to execute.
Custom prompt setting
You can specify the following prompt constant at the 2nd argument of connect().
-
For Juniper JUNOS
- For Linux or other UNIX platforms
Usage for Parser
Instantiating a parser
Parse the command response
The first argument of parse() is the executed Cisco IOS command. Required for the parser to select the format.
Limitations
Telnet client of this library requires the PHP's low-level sockets extension (ext-sockets) for the underlying library.
Authors
- marbocub - Initial work
License
This project is licensed under the MIT License - see the LICENSE file for details.