PHP code example of phpty / tty
1. Go to this page and download the library: Download phpty/tty library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
phpty / tty example snippets
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);
});
}