Download the PHP package cpehub/php-telnet without Composer

On this page you can find all versions of the php package cpehub/php-telnet. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-telnet

php-telnet

A standards-compliant Telnet client for PHP.

phpcs phpstan phpmd phpunit

php-telnet speaks the Telnet protocol correctly: it escapes IAC per RFC 854/855, negotiates options with the RFC 1143 "Q Method" state machine, and answers the server's negotiation automatically while you wait for a prompt. It ships with a pluggable transport layer (raw sockets by default, or streams with optional TLS).

Upgrading from v1? The behaviour changed in a few important ways (most notably timelimit is now in milliseconds). See Upgrading from v1 to v2.

Requirements

Installation

Basic usage

sendMessage() waits for the configured prompt pattern and returns the clean response text (Telnet protocol bytes are stripped for you).

Advanced usage

Build and exchange raw command sequences with CommandSequence:

Note: CommandSequence::compile() doubles IAC (0xFF) bytes in text and subnegotiation parameters as required by RFC 854/855 — pass raw bytes and let the library escape them; do not double 0xFF yourself.

TLS ("telnets")

The default transport uses raw sockets. For an encrypted connection, inject a StreamTransport created via its tls() named constructor (port 992 by default):

Logging

Pass any PSR-3 LoggerInterface to the constructor, or set it later:

Credentials are never logged: login() sends the password through a redacted path, so the log shows send: <redacted> instead of the raw bytes.

Exceptions

All exceptions extend Cpehub\Telnet\Exceptions\TelnetException:

Catching TelnetException still catches everything. Exception messages no longer embed buffer contents (a security hardening change); use the value returned by the send*/await* methods to read the response.

Class synopsis

Cpehub\Telnet\Client

Cpehub\Telnet\Components\CommandSequence

Cpehub\Telnet\Components\Command constants

See https://www.rfc-editor.org/rfc/rfc854 for details.

Cpehub\Telnet\Components\Option constants

Cpehub\Telnet\Components\Printer constants

Upgrading from v1 to v2

v2.0.0 is the first substantial release since v1.0.2. Public method signatures are preserved, but three behavioural contracts changed. Read this before you composer update.

# Change v1.0.2 v2.0.0 What to do
A timelimit unit seconds milliseconds Multiply your old second values by 1000. new Client($ip, 23, 5) meant 5 s in v1; in v2 it means 5 ms — use 5000. The default is unchanged in effect (1 s → 1000 ms). Applies to the constructor and the per-call $timelimit in sendMessage()/awaitSequence()/awaitPrompt().
B CommandSequence::compile() escapes IAC raw 0xFF passed through 0xFF doubled in data and SB params (RFC 854/855) Stop doubling 0xFF yourself; pass raw bytes and let the library escape them.
C login() rewritten fixed WILL/DO burst + canned reply; waited for the literal string 'Password:' negotiation handled automatically by the read loop; password prompt matched with ~password[: ]*$~i (case-insensitive, anchored) Usually nothing. If you relied on the old negotiation choreography, review it. Make sure a prompt pattern is configured (see D).
D awaitPrompt() validates the pattern passed empty/null to preg_match and looped throws TelnetException when no pattern is configured/passed, or when the regex is invalid Call setPromptPattern('...') or pass a pattern explicitly.
E New Composer requirements only php: ^8.2 adds ext-sockets and psr/log Ensure ext-sockets is enabled. psr/log is pulled in automatically (in v1 it was missing and the autoload could fatal).
F setLogger() fixed infinite recursion (stack overflow on first call) assigns the logger Nothing — it just works now.
G Constant renamed Command::ABOUT_OUTPUT Command::ABORT_OUTPUT (old name kept as a deprecated alias, same value 0xF5) Migrate to Command::ABORT_OUTPUT.
H No buffer in errors/logs exception messages/logs embedded the raw buffer messages omit buffer contents (security hardening) If you parsed exception text to recover the response body, use the value returned by the send*/await* methods instead.

Additive (non-breaking) improvements you can adopt:

Before / after


All versions of php-telnet with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-sockets Version *
psr/log Version ^1.1 || ^2.0 || ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package cpehub/php-telnet contains the following files

Loading the files please wait ...