1CLI-Prompt
2==========
3
4While prompting for user input using `fgets()` is quite easy, sometimes you
5need to prompt for sensitive information. In these cases, the characters typed
6in by the user should not be directly visible, and this is quite a pain to
7do in a cross-platform way.
8
9This tiny package fixes just that for you:
10
11```php
12<?php
13
14echo 'Say hello: ';
15
16$answer = Seld\CliPrompt\CliPrompt::hiddenPrompt();
17
18echo 'You answered: '.$answer . PHP_EOL;
19
20// Output in the CLI:
21//
22// Say hello:
23// You answered: hello
24```
25
26Installation
27------------
28
29`composer require seld/cli-prompt`
30
31API
32---
33
34- `Seld\CliPrompt\CliPrompt::hiddenPrompt($allowFallback = false);`
35
36 > Prompts the user for input and hides what they type. If this fails for any
37 > reason and `$allowFallback` is set to `true` the prompt will be done using
38 > the usual `fgets()` and characters will be visible.
39
40- `Seld\CliPrompt\CliPrompt::prompt();`
41
42 > Regular user prompt for input with characters being shown on screen.
43
44In both cases, the trailing newline the user enters when submitting the answer
45is trimmed.
46
47Requirements
48------------
49
50PHP 5.3 and above
51
52License
53-------
54
55CLI-Prompt is licensed under the MIT License - see the LICENSE file for details
56
57Acknowledgments
58---------------
59
60- This project uses hiddeninput.exe to prompt for passwords on Windows, sources
61 and details can be found on the [github page of the project](https://github.com/Seldaek/hidden-input).
62