Download the PHP package nashgao/interactive-shell without Composer

On this page you can find all versions of the php package nashgao/interactive-shell. 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 interactive-shell

Interactive Shell

License: MIT PHP Version

Interactive shell library with pluggable transports and streaming support. Build MySQL-like CLI interfaces for your PHP applications with built-in command parsing, history, formatting, and real-time message streaming capabilities.

Documentation

Features

Requirements

Optional Extensions

Installation

Quick Start

Standard Shell (Request/Response)

Example Session:

Streaming Shell (Real-time Messages)

Example Streaming Session:

Output Formats

The shell supports four output formats that can be selected via --format option or \G terminator:

Table Format (Default)

Output:

JSON Format

Output:

CSV Format

Output:

Vertical Format (MySQL \G style)

Output:

Built-in Commands

These commands work offline without server connection:

Command Description Example
help Display help message with available commands help
exit, quit Exit the shell and save session exit
status Show connection status and session metrics status
clear Clear the terminal screen clear
history Display command history history
alias [name=cmd] Show all aliases or set a new alias alias ls=list
unalias <name> Remove an alias unalias ls

Status Output Example:

Streaming Commands

Additional commands available in StreamingShell:

Command Description Example
filter <pattern> Set message filter expression filter sensor/temperature
filter show Show current filter filter show
filter clear Clear filter (show all messages) filter clear
pause Pause message streaming pause
resume Resume message streaming resume
stats Show streaming statistics stats

Filter Patterns:

Configuration

Shell Configuration Options

Transport Configuration

Swoole Socket Transport

Custom Transport Implementation

Implement the TransportInterface to create custom transport backends:

Usage:

Server-Side Command Handlers

Create custom command handlers for your application by implementing CommandHandlerInterface:

Creating a Handler

Registering Handlers

Use CommandRegistry to register your handlers:

Hyperf Framework Integration

Automatic Setup

The library provides a ConfigProvider for Hyperf auto-discovery:

Configuration

Edit config/autoload/interactive_shell.php:

Connecting to a Running Server

Once the Hyperf server is running, connect using a client:

Built-in Hyperf Handlers

When running in Hyperf, these additional commands are available:

Command Description
config <key> Get configuration values using dot notation
routes List all registered HTTP routes
container <abstract> Inspect container bindings
command <name> Execute Hyperf console commands

API Reference

Core Classes

Class Description
Shell Standard interactive shell with request/response model
StreamingShell Bidirectional streaming shell for real-time messages
ShellParser Command parser with quote handling and options
OutputFormatter Formats command results in table/JSON/CSV/vertical
MessageFormatter Formats streaming messages with timestamps
HistoryManager Manages command history with persistence
AliasManager Manages command aliases
ShellState Tracks session state and metrics

Transport Classes

Class Description
SwooleSocketTransport Swoole coroutine-based Unix socket transport (with streaming support)
TransportInterface Interface for custom transport implementations
StreamingTransportInterface Extended interface for streaming transports

Data Classes

Class Description
ParsedCommand Parsed command with arguments and options
CommandResult Command execution result with data and metadata
Message Streaming message with topic and payload
FilterExpression Message filter for streaming mode
OutputFormat Enum for output format types

Shell Methods

StreamingShell Methods

Advanced Features

Multi-line Input

Use \ at the end of a line to continue input on the next line:

History Navigation

Alias Expansion

Session Persistence

The shell automatically saves:

Performance Considerations

Streaming Mode Performance

The streaming shell uses Swoole coroutines for true concurrent I/O — message receiving, display, and user input each run in their own coroutine.

Output Format Performance

Format Speed Use Case
JSON Fastest Machine-readable, API integration
CSV Fast Data export, spreadsheet import
Table Moderate Human-readable terminal output
Vertical Moderate Detailed single-record inspection

Testing

Test Structure

Suite Directory Purpose
Unit tests/Unit/ Component isolation tests
Integration tests/Integration/ Cross-component interactions
Specification tests/Specification/ Consumer-perspective behavior specs
E2E tests/E2E/ Full system scenarios (requires Swoole)

Running Tests

Key Test Areas

Contributing

Contributions are welcome! Please follow these guidelines:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Write tests for new functionality
  4. Ensure all tests pass (composer test)
  5. Ensure PHPStan passes at level max (composer phpstan)
  6. Commit your changes (git commit -m 'Add amazing feature')
  7. Push to the branch (git push origin feature/amazing-feature)
  8. Open a Pull Request

Code Standards

License

This library is licensed under the MIT License. See the LICENSE file for details.


Built with ❤️ by Nash Gao


All versions of interactive-shell with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
ext-swoole Version *
symfony/console Version ^6.0|^7.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 nashgao/interactive-shell contains the following files

Loading the files please wait ...