2017 © Pedro Peláez
 

library cli-prompt

Allows you to prompt for user input on the command line, and optionally hide the characters they type

image

seld/cli-prompt

Allows you to prompt for user input on the command line, and optionally hide the characters they type

  • Saturday, March 18, 2017
  • by Seldaek
  • Repository
  • 5 Watchers
  • 192 Stars
  • 6,993,009 Installations
  • PHP
  • 17 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 5 Versions
  • 13 % Grown

The README.md

CLI-Prompt

While prompting for user input using fgets() is quite easy, sometimes you need to prompt for sensitive information. In these cases, the characters typed in by the user should not be directly visible, and this is quite a pain to do in a cross-platform way., (*1)

This tiny package fixes just that for you:, (*2)

<?php

echo 'Say hello: ';

$answer = Seld\CliPrompt\CliPrompt::hiddenPrompt();

echo 'You answered: '.$answer . PHP_EOL;

// Output in the CLI:
// 
// Say hello:
// You answered: hello

Installation

composer require seld/cli-prompt, (*3)

API

  • Seld\CliPrompt\CliPrompt::hiddenPrompt($allowFallback = false);, (*4)

    Prompts the user for input and hides what they type. If this fails for any reason and $allowFallback is set to true the prompt will be done using the usual fgets() and characters will be visible., (*5)

  • Seld\CliPrompt\CliPrompt::prompt();, (*6)

    Regular user prompt for input with characters being shown on screen., (*7)

In both cases, the trailing newline the user enters when submitting the answer is trimmed., (*8)

Requirements

PHP 5.3 and above, (*9)

License

CLI-Prompt is licensed under the MIT License - see the LICENSE file for details, (*10)

Acknowledgments

  • This project uses hiddeninput.exe to prompt for passwords on Windows, sources and details can be found on the github page of the project.

The Versions

18/03 2017

dev-master

9999999-dev

Allows you to prompt for user input on the command line, and optionally hide the characters they type

  Sources   Download

MIT

The Requires

  • php >=5.3

 

console cli input hidden prompt

18/03 2017

1.0.3

1.0.3.0

Allows you to prompt for user input on the command line, and optionally hide the characters they type

  Sources   Download

MIT

The Requires

  • php >=5.3

 

console cli input hidden prompt

18/04 2016

1.0.2

1.0.2.0

Allows you to prompt for user input on the command line, and optionally hide the characters they type

  Sources   Download

MIT

The Requires

  • php >=5.3

 

console cli input hidden prompt

09/01 2016

1.0.1

1.0.1.0

Allows you to prompt for user input on the command line, and optionally hide the characters they type

  Sources   Download

MIT

The Requires

  • php >=5.3

 

console cli input hidden prompt

30/04 2015

1.0.0

1.0.0.0

Allows you to prompt for user input on the command line, and optionally hide the characters they type

  Sources   Download

MIT

The Requires

  • php >=5.3

 

console cli input hidden prompt