GitXplorerGitXplorer
S

cli-prompt

public
247 stars
7 forks
0 issues

Commits

List of commits on branch main.
Verified
b10aa66379346e884a76ba674a608bbb6a9fad35

Update CI

SSeldaek committed 5 months ago
Verified
4cf2d1bc2cb45f98c6488e47af0944d770994ceb

Enable dependabot, remove deprecated GH actions code

SSeldaek committed 5 months ago
Verified
9c345a61e643059f286502eb9eacfe2052598e7c

Create SECURITY.md

SSeldaek committed 6 months ago
Verified
b8dfcf02094b8c03b40322c229493bb2884423c5

Make lint run on php8

SSeldaek committed 4 years ago
Verified
e3cb6e0c712948303cee39e2ae186d8fced0c148

Add phpstan/lint tasks

SSeldaek committed 4 years ago
Unverified
a19a7376a4689d4d94cab66ab4f3c816019ba8dd

Handle shell_exec failures gracefully, closes #3

SSeldaek committed 8 years ago

README

The README file for this repository.

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

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

    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.

  • Seld\CliPrompt\CliPrompt::prompt();

    Regular user prompt for input with characters being shown on screen.

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

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