Home

Awesome

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.

This tiny package fixes just that for you:

<?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

API

In both cases, the trailing newline the user enters when submitting the answer is trimmed.

Requirements

PHP 5.3 and above

License

CLI-Prompt is licensed under the MIT License - see the LICENSE file for details

Acknowledgments