1. Go to this page and download the library: Download php-tui/term 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/ */
php-tui / term example snippets
$terminal = Terminal::new();
// queue an action
$terminal->queue(Actions::printString('Hello World'));
// flush the queue to the terminal
$terminal->flush();
// or you can execute it directly
$terminal->execute(Actions::printString('Hello World'));
while (true) {
while ($event = $terminal->events()->next()) {
if ($event instanceof CodedKeyEvent) {
if ($event->code === KeyCode::Esc) {
// escape pressed
}
}
if ($event instanceof CharKeyEvent) {
if ($event->char === 'c' && $event->modifiers === KeyModifiers::CONTROL) {
// ctrl-c pressed
}
}
}
usleep(10000);
}