Download the PHP package soloterm/screen without Composer

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

Solo Screen

Screen is a terminal renderer written in pure PHP. It powers Solo for Laravel and can be used to build rich text-based user interfaces in any PHP application.

[!NOTE] Screen is a library intended to be integrated into PHP applications. It is not a standalone terminal application.

About terminal renderers

A terminal renderer processes text and ANSI escape sequences to create a virtual representation of terminal output. Unlike a full terminal emulator, Screen focuses specifically on correctly interpreting and rendering text content with formatting rather than handling input, interactive sessions, or process management.

Terminal renderers interpret escape sequences to:

Screen implements this functionality in pure PHP, allowing developers to build terminal user interfaces without relying on external dependencies or native code.

Why this exists

Screen was originally created to solve a specific problem in Solo for Laravel.

Solo provides a TUI (Text User Interface) that runs multiple processes simultaneously in separate panels, similar to tmux. However, when these processes output ANSI escape codes for cursor movement and screen manipulation, they could potentially "break out" of their visual containers and interfere with other parts of the interface.

To solve this problem, Screen creates a virtual terminal buffer where:

  1. All ANSI operations (cursor movements, color changes, screen clears) are safely interpreted within an isolated environment
  2. The final rendered state is captured after all operations are processed
  3. Only the final visual output is displayed to the user's terminal

This approach provides complete control over how terminal output is rendered, ensuring that complex ANSI operations stay contained within their designated areas. While initially built for Solo, Screen has evolved into a standalone library that can be used in any PHP application requiring terminal rendering.

Features

Installation

Install via Composer:

Requirements

Basic usage

Here's a simple example of using Screen:

Core concepts

Screen operates with several key components:

Screen

The main class that coordinates all functionality. It takes care of cursor positioning, content writing, and rendering the final output.

Buffers

Screen uses multiple buffer types to track content and styling:

ANSI processing

Screen correctly interprets ANSI escape sequences for:

Architecture

Screen uses a dual-buffer architecture to separate content from styling:

This separation allows Screen to efficiently track what changed and optimize rendering.

Advanced features

Rendering at arbitrary positions (popup windows, panels)

When building TUIs with multiple Screen instances rendered at different positions (like popup windows or panels), you need to handle cursor positioning carefully. Screen's output() method uses relative cursor positioning to avoid the "pending wrap state" problem that causes rendering issues across different terminals.

The pending wrap problem

When a line is filled to exactly the terminal width, terminals enter a "pending wrap" state. The behavior of \n and \r in this state varies between terminal emulators:

This inconsistency can cause content to appear offset by an entire screen width in some terminals.

How Screen solves this

Screen's output() method uses DEC save/restore cursor (DECSC/DECRC) with cursor down (CUD) sequences instead of newlines:

This approach:

Rendering a Screen at a specific position

To render a Screen at a specific position in your TUI:

The Screen will render its content starting from wherever the cursor is positioned, with each line placed relative to that origin point.

Differential rendering

For high-performance applications like TUIs with frequent updates, Screen supports differential rendering that only outputs changed lines:

This is particularly useful when building interfaces that update at high frame rates (e.g., 40 FPS) where re-rendering the entire screen would be wasteful.

Cursor positioning

Text styling

Screen manipulation

Supported ANSI codes

Screen supports a comprehensive set of ANSI escape sequences:

Cursor movement (CSI sequences)

Code Name Description
ESC[nA CUU Cursor up n lines
ESC[nB CUD Cursor down n lines
ESC[nC CUF Cursor forward n columns
ESC[nD CUB Cursor backward n columns
ESC[nE CNL Cursor to beginning of line, n lines down
ESC[nF CPL Cursor to beginning of line, n lines up
ESC[nG CHA Cursor to column n
ESC[n;mH CUP Cursor to row n, column m
ESC[nI CHT Cursor forward n tab stops
ESC7 DECSC Save cursor position
ESC8 DECRC Restore cursor position

Erase functions

Code Name Description
ESC[0J ED Erase from cursor to end of screen
ESC[1J ED Erase from start of screen to cursor
ESC[2J ED Erase entire screen
ESC[0K EL Erase from cursor to end of line
ESC[1K EL Erase from start of line to cursor
ESC[2K EL Erase entire line

Scrolling

Code Name Description
ESC[nS SU Scroll up n lines
ESC[nT SD Scroll down n lines
ESC[nL IL Insert n lines at cursor

Text styling (SGR - Select Graphic Rendition)

Code Description
0 Reset all attributes
1 Bold
2 Dim
3 Italic
4 Underline
5 Blink
7 Reverse video
8 Hidden
9 Strikethrough
22 Normal intensity (not bold/dim)
23 Not italic
24 Not underlined
25 Not blinking
27 Not reversed
28 Not hidden
29 Not strikethrough
30-37 Foreground color (standard)
38;5;n Foreground color (256-color)
38;2;r;g;b Foreground color (RGB)
39 Default foreground
40-47 Background color (standard)
48;5;n Background color (256-color)
48;2;r;g;b Background color (RGB)
49 Default background
90-97 Foreground color (bright)
100-107 Background color (bright)

Custom integrations

You can respond to terminal queries by setting a callback:

[!NOTE] This is still a work in progress. We need some more tests / use cases here.

Example: building a simple UI

Handling unicode and wide characters

Screen properly handles Unicode characters including emoji and CJK characters that take up multiple columns:

Testing

Screen includes a comprehensive test suite with visual comparison testing that validates output against real terminal behavior.

Available test commands

Command Description
composer test Run tests without screenshot generation
composer test:screenshots Generate fixtures in a fresh relay window (auto-targets a supported terminal, or use --terminal)
composer test:missing Generate missing or out-of-sync fixtures in fresh iTerm and Ghostty relays (or one terminal via --terminal)
composer test:failed Re-run only tests that failed in the previous wrapped PHPUnit run
composer test:screenshots:failed Re-run last failed tests in screenshot mode
composer test:missing:failed Re-run last failed tests in missing-fixture mode
composer test:failures Re-run failed tests first, stop on first failure
composer test:fixtures Validate fixture integrity across terminals

You can pass additional PHPUnit options using --:

Visual testing

Screen employs screenshot-based testing that compares rendered output against real terminal behavior. The system supports both iTerm2 and Ghostty terminals to ensure cross-terminal compatibility.

How it works:

  1. The test renders content in a real terminal (iTerm2 or Ghostty)
  2. It captures a screenshot using macOS's CGWindowListCreateImage API
  3. It runs the same content through the Screen renderer
  4. It captures another screenshot
  5. It compares the screenshots pixel-by-pixel using ImageMagick

This ensures Screen's rendering accurately matches real terminal behavior for:

Requirements for visual testing

composer test:screenshots and composer test:missing launch fresh terminal relay windows to keep capture dimensions consistent with CI. iTerm is resized automatically to 180x32; Ghostty is opened to a calibrated window size and prompts if dimensions still need adjustment.

Fixture structure

Fixtures are stored per-terminal to account for rendering differences:

When running tests without screenshot generation, the system uses stored fixtures for comparison, making tests fast and suitable for CI/CD pipelines. In CI (where no terminal is available), iTerm fixtures are used since we validate that iTerm and Ghostty fixtures are identical.

CI Behavior

The Tests workflow enforces fixture hygiene and parity across a Linux PHP matrix:

Current workflow action majors are modernized to avoid stale runtime warnings:

Platform Caveats

Two specific multibyte parity edge cases are intentionally validated on macOS only and skipped on non-Darwin runners:

Contributing

Contributions are welcome! Please feel free to submit a pull request.

License

The MIT License (MIT).

Support

This is free! If you want to support me:

Related Projects

Screen is part of the SoloTerm ecosystem of Laravel and PHP development tools:

Credits

Solo Screen was developed by Aaron Francis. If you like it, please let me know!


All versions of screen with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
soloterm/grapheme Version ^v1.1.0
ext-mbstring Version *
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 soloterm/screen contains the following files

Loading the files please wait ...