PHPackages                             phpty/tty - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. phpty/tty

ActiveLibrary

phpty/tty
=========

Reads and changes the state of the Tty this process is attached to: raw mode, size, and whether a stream is a Tty at all.

v0.2.0(yesterday)03↑2900%MPL-2.0PHP ^7.4 || ^8.0

Since Jul 19Compare

[ Source](https://github.com/phpty-org/tty)[ Packagist](https://packagist.org/packages/phpty/tty)[ RSS](/packages/phpty-tty/feed)WikiDiscussions Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

phpty/tty
=========

[](#phptytty)

Reads and changes the state of the Tty this process is attached to: raw mode, size, and whether a stream is a Tty at all. This is the capability PHP lacks and Ruby gets from `io-console`.

> **Read-only mirror.** The canonical development repository is [phpty-org/phpty](https://github.com/phpty-org/phpty), a monorepo. This `phpty/tty` repository is split out from it for distribution and is read-only: issues and pull requests are disabled, and any pull request opened here is closed automatically. Please contribute upstream.

Install
-------

[](#install)

```
composer require phpty/tty
```

Requirements
------------

[](#requirements)

- PHP `^7.4 || ^8.0`, on a Unix host (macOS or Linux)
- The `ffi` extension is optional: with it, Tty uses the faster Ffi Backend; without it, Tty falls back to shelling out to `stty`, which works everywhere but pays a fork+exec per state change.

Usage
-----

[](#usage)

```
use PhPty\Tty\Tty;
use PhPty\Tty\RawOptions;

$tty = new Tty();

if ($tty->isTty()) {
    $size = $tty->getWinsize();
    echo "{$size->rows()}x{$size->cols()}\n";

    // Enter raw mode for the duration of the callback, restoring the prior
    // state on the way out — even if the callback throws. RawOptions keeps
    // signals on by default; pass one to change that or the read thresholds.
    $byte = $tty->withRawMode(static function () {
        return \fread(\STDIN, 1);
    });
}
```

License
-------

[](#license)

MPL-2.0. See [LICENSE](LICENSE) and, for how licensing works across PhPty, [the monorepo's LICENSE](https://github.com/phpty-org/phpty/blob/main/LICENSE).

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance100

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity28

Early-stage or recently created project

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e1cc4bc1729b858086681a12494fda6cced8f26db3d0928ae4d81c68ddf8dc06?d=identicon)[zonuexe](/maintainers/zonuexe)

---

Tags

ffittytermiosraw-modestty

### Embed Badge

![Health badge](/badges/phpty-tty/health.svg)

```
[![Health](https://phpackages.com/badges/phpty-tty/health.svg)](https://phpackages.com/packages/phpty-tty)
```

###  Alternatives

[satur.io/duckdb

DuckDB API for PHP

86104.5k6](/packages/saturio-duckdb)[ffi/preprocessor

Simple C Preprocessor

2637.1k13](/packages/ffi-preprocessor)[ffi/location

PHP library for determining the physical location of binaries

1339.8k7](/packages/ffi-location)[serafim/ffi-sdl

SDL FFI bindings for the PHP language

324.6k3](/packages/serafim-ffi-sdl)[ffi/var-dumper

List of symfony/var-dumper casters with FFI support

2011.3k4](/packages/ffi-var-dumper)[foysal50x/h3-php

PHP FFI bindings for Uber's H3 hexagonal hierarchical geospatial indexing system

139.4k](/packages/foysal50x-h3-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
