Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Exemplo de UI básico em script CLI usando PHP
<?php
buildInterface();
getMenu();
getSelect();
function buildInterface(){
clear();
for($x=1;$x<=28;$x++){
gotoxy(1, $x);
echo chr(186);
gotoxy(80,$x);
echo chr(186);
}
for($i=1;$i<=80;$i++){
gotoxy($i, 1);
echo ($i == 1) ? chr(201) : ($i ==80 ? chr(187) : chr(205));;
gotoxy($i, 22);
echo ($i == 1) ? chr(204) : ($i ==80 ? chr(185) : chr(205));
gotoxy($i, 28);
echo ($i == 1) ? chr(200) : ($i ==80 ? chr(188) : chr(205));
}
}
function clear(){
for($x=0;$x<=28;$x++){
for($i=1;$i<=80; $i++){
echo chr(0);
}
echo "\n";
}
}
function getMenu(){
gotoxy(5,5);
echo "1 - Realizar Login";
gotoxy(5,6);
echo "2 - Sair";
}
function getSelect(){
gotoxy(5,25);
$msg = "Insira o comando desejado: ";
echo $msg;
$opt = stream_get_line(STDIN, 1024, PHP_EOL);
if($opt == 1){
gotoxy(5,26);
echo "Entrou!!!";
gotoxy(5,29);
}
else{
exit(0);
}
}
function gotoxy($x,$y){
echo "\033[H";
echo "\033[{$x}C";
echo "\033[{$y}B";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.