PHP code example of pointybeard / helpers-cli-prompt
1. Go to this page and download the library: Download pointybeard/helpers-cli-prompt 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/ */
pointybeard / helpers-cli-prompt example snippets
include __DIR__ . "/vendor/autoload.php";
use pointybeard\Helpers\Cli\Prompt\Prompt;
use pointybeard\Helpers\Cli\Message\Message;
use pointybeard\Helpers\Cli\Colour\Colour;
// The most basic of prompt
$name = (new Prompt("Enter your name"))->display();
// Enter your name:
// Prompt with a default value
$proceed = (new Prompt("Proceed with installation?"))
->default('yes')
->display()
;
// Proceed with installation? [yes]:
// A prompt that does not echo the value as it is typed
$password = (new Prompt)
->prompt("Enter password")
->flags(Prompt::FLAG_SILENT)
->display()
;
// Prompt with a custom Cli/Message/Message object instead of a string
$value = (new Prompt)
->prompt((new Message)
->message("Some fancy looking prompt")
->foreground(Colour::FG_BLACK)
->background(Colour::BG_YELLOW)
->flags(NULL)
)
->display()
;
// Validate the input
$emailAddress = (new Prompt("Enter Email Address"))
->validator(function($input) {
if(strlen(trim($input)) <= 0) {
(new Message)
->message("Email address is