1. Go to this page and download the library: Download prateekbhujel/php-terminal 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/ */
prateekbhujel / php-terminal example snippets
$password = Terminal::readSecret('Password: ');
use Terminal\Key;
use Terminal\ModeToken;
use Terminal\Stream;
use Terminal\Terminal;
Terminal::enableAnsi(Stream::Stdout);
$mode = Terminal::enableRawMode();
try {
$key = Terminal::readKey();
if ($key === Key::Up) {
Terminal::write("up\n");
} elseif (is_string($key)) {
Terminal::write("typed {$key}\n");
}
} finally {
if ($mode instanceof ModeToken) {
Terminal::restoreMode($mode);
}
}
if (!extension_loaded('terminal')) {
die("terminal is not loaded\n");
}
use Terminal\Terminal;
use Terminal\ModeToken;
var_dump(Terminal::getBackend());
var_dump(Terminal::isTty());
var_dump(Terminal::supportsAnsi());
var_dump(Terminal::getSize());
Terminal::write("hello from terminal\n");
$mode = Terminal::enableRawMode();
if ($mode instanceof ModeToken) {
try {
$key = Terminal::readKey(0.5);
} finally {
Terminal::restoreMode($mode);
}
}
sh
pie install prateekbhujel/php-terminal
ini
extension=terminal
ini
extension=php_terminal.dll
sh
pie install prateekbhujel/php-terminal
ini
extension=php_terminal.dll
sh
git clone https://github.com/prateekbhujel/php-terminal.git
cd php-terminal
git checkout v0.6.0
phpize
./configure
make
make test
sh
php -d extension=modules/terminal.so examples/streams.php
php -d extension=modules/terminal.so examples/prompt.php
sh
php -d extension=modules/terminal.so examples/streams.php
php -d extension=modules/terminal.so examples/prompt.php
bat
set PHP_BIN=C:\xampp\php\php.exe
%PHP_BIN% -i | findstr /C:"PHP Version" /C:"Thread Safety" /C:"Architecture" /C:"Compiler"
%PHP_BIN% --ini
text
C:\xampp\php\ext
text
C:\xampp\php\php.ini
ini
extension=php_terminal.dll
bat
%PHP_BIN% -m | findstr terminal
%PHP_BIN% examples\doctor.php
%PHP_BIN% examples\prompt.php
sh
git clone https://github.com/prateekbhujel/php-terminal.git
cd php-terminal
PHP_BIN=/Applications/XAMPP/xamppfiles/bin/php
PHPIZE="$(dirname "${PHP_BIN}")/phpize"
PHP_CONFIG="$(dirname "${PHP_BIN}")/php-config"
"${PHPIZE}"
if [ "$(uname -s)" = "Darwin" ]; then
PHP_ARCH=$("${PHP_BIN}" -r 'echo php_uname("m");')
CFLAGS="-arch ${PHP_ARCH}" \
LDFLAGS="-arch ${PHP_ARCH}" \
./configure --with-php-config="${PHP_CONFIG}"
else
./configure --with-php-config="${PHP_CONFIG}"
fi
make
make test
sudo make install
sh
"${PHP_BIN}" --ini
sh
"${PHP_BIN}" -m | grep terminal
"${PHP_BIN}" examples/doctor.php
"${PHP_BIN}" examples/prompt.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.