1. Go to this page and download the library: Download tflori/hugga 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/ */
tflori / hugga example snippets
$console = new Hugga\Console;
$name = $console->ask('What is your name?');
$console->line('${fg:white;bg:white;bold}Nice to meet you ' . $name . '!');
$console->line('You will see this', Hugga\Console::WEIGHT_NORMAL);
$console->line('You will not see this', Hugga\Console::WEIGHT_LOWER);
$console->increaseVerbosity();
$console->line('Now you can see this', Hugga\Console::WEIGHT_LOWER);
$console->line('But this is just a debug message', Hugga\Console::WEIGHT_DEBUG);
//$console->setVerbosity(Hugga\Console::WEIGHT_DEBUG);
//$console->debug(
// ['key' => 'value', 'recursive' => ['string', 42, null, true]],
// Hugga\Console::DEBUG_PRETTY ^ Hugga\Console::DEBUG_COLOR
// );
$console = new Hugga\Console;
$console->line('Hello world');
$console->write('no newline here');
$console->line('extra detail', Hugga\Console::WEIGHT_LOWER); // hidden at normal verbosity
$console->increaseVerbosity(); // lower threshold — now WEIGHT_LOWER is visible
$console->line('debug dump', Hugga\Console::WEIGHT_DEBUG); // still hidden; needs another increaseVerbosity()
$console->info('Operation complete'); // informational, stdout
$console->warn('Disk almost full'); // warning, stderr
$console->error('File not found'); // error, stderr
$console->line('${bold;cyan}Section header');
$console->line('${red}Error:${r} something went wrong');
$console->line('${fg:blue;bg:white}Blue on white');
$console->line('${u}underlined${r} and ${bold}bold${r}');
$console->write('Processing … ${yellow}in progress');
// ... do work ...
$console->delete('in progress'); // removes that exact string
$console->line('${green}done');
$console->write('Loading…');
$console->deleteLine(); // removes the entire current line
$name = $console->ask('What is your name?', 'Anonymous');
if ($console->ask(new Hugga\Input\Question\Confirmation('Are you sure?'))) {
// confirmed
}
$console->ask(
(new Hugga\Input\Question\Choice($options, 'Pick one:'))
->limit(10) // show at most 10 options at a time
->returnValue() // return the value instead of the key
);