PHP code example of bentools / simple-cli
1. Go to this page and download the library: Download bentools/simple-cli 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/ */
bentools / simple-cli example snippets
# php thatscript.php --file=some-file foobar
ction BenTools\SimpleCli\getOption;
use function BenTools\SimpleCli\getArgument;
use function BenTools\SimpleCli\writeLn;
use function BenTools\SimpleCli\text;
use function BenTools\SimpleCli\ask;
use function BenTools\SimpleCli\askHidden;
use function BenTools\SimpleCli\confirm;
use function BenTools\SimpleCli\error;
use function BenTools\SimpleCli\success;
getOption('file'); // some-file
getArgument(0); // foobar
writeLn(text('Hey there!')->yellow());
$user = ask('What is your username?', $default = 'anonymous');
$password = askHidden('Enter your password');
if ('123456' === $password && confirm('Really?')) {
error('Nope nope nope!', $exit = true);
}
success('Done!');