Skip to content

Instantly share code, notes, and snippets.

@davidneimeyer
Created March 3, 2015 06:34
Show Gist options
  • Save davidneimeyer/27c984252d2056c3bddc to your computer and use it in GitHub Desktop.
Save davidneimeyer/27c984252d2056c3bddc to your computer and use it in GitHub Desktop.
A non echoing prompt reader for CLImate
<?php
use League\CLImate\Util\Reader\Stdin;
/**
* StdinNoEcho
*
* This is a quick hack to implement https://github.com/thephpleague/climate/issues/31
* Informed by http://stackoverflow.com/a/2654048
*/
class StdinNoEcho extends Stdin
{
public function line()
{
exec('stty -g', $output); // save original terminal setting
exec('stty -echo'); // turn-off echoing.
$response = parent::line();
exec('stty ' . implode("\n", $output)); // restore
return $response;
}
}
@sagikazarmark
Copy link

Great stuff, good workaround.

For an ultimate solution (included in the core package) windows support (unfortunately) should also be solved somehow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment