We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 088483a commit d864ed9Copy full SHA for d864ed9
src/CLI.php
@@ -658,6 +658,25 @@ public static function prompt(string $question, array | string $options = null)
658
return $answer;
659
}
660
661
+ /**
662
+ * Prompt a question with secret answer.
663
+ *
664
+ * @param string $question The question to prompt
665
666
+ * @see https://dev.to/mykeels/reading-passwords-from-stdin-in-php-1np9
667
668
+ * @return string The secret answer
669
+ */
670
+ public static function secret(string $question) : string
671
+ {
672
+ $question .= ': ';
673
+ \fwrite(\STDOUT, $question);
674
+ \exec('stty -echo');
675
+ $secret = \trim((string) \fgets(\STDIN));
676
+ \exec('stty echo');
677
+ return $secret;
678
+ }
679
+
680
/**
681
* Creates a well formatted table.
682
*
0 commit comments