Zend Framework 2 Console Prompt Password

dev-master 2015-04-30 10:34 UTC


ZF2 Console Prompt Password, for prompting for passwords via the console without echoing back characters to the screen.

If you are using Zend Framework >= 2.4 then you don't need this package. The console prompt was merged into the framework See


To prompt for a password, and store the result in $secret

$passwordPrompt = new \Richardjh\Zf2Password\Console\Prompt\Password;
$secret = $passwordPrompt->prompt();

You can set the prompt text to something other than "Password: " or for translations.

$passwordPrompt = new \Richardjh\Zf2Password\Console\Prompt\Password('Enter the secret: ');
$secret = $passwordPrompt->prompt();

You can prompt for a password, using the linux approach of echoing back nothing, not even the *s

$passwordPrompt = new \Richardjh\Zf2Password\Console\Prompt\Password('Enter the secret: ', false);
$secret = $passwordPrompt->prompt();