本文整理匯總了PHP中Terminus\Helpers\Input::promptSecret方法的典型用法代碼示例。如果您正苦於以下問題:PHP Input::promptSecret方法的具體用法?PHP Input::promptSecret怎麽用?PHP Input::promptSecret使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Terminus\Helpers\Input
的用法示例。
在下文中一共展示了Input::promptSecret方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: login
/**
* Log in as a user
*
* ## OPTIONS
* [<email>]
* : Email address to log in as.
*
* [--password=<value>]
* : Log in non-interactively with this password. Useful for automation.
*
* [--machine-token=<value>]
* : Authenticate using an Auth0 token
*
* [--session=<value>]
* : Authenticate using an existing session token
* [--debug]
* : dump call information when logging in.
*/
public function login($args, $assoc_args)
{
// Try to login using a machine token, if provided.
if (isset($assoc_args['machine-token']) || empty($args) && isset($_SERVER['TERMINUS_MACHINE_TOKEN'])) {
if (isset($assoc_args['machine-token'])) {
$token = $assoc_args['machine-token'];
} elseif (isset($_SERVER['TERMINUS_MACHINE_TOKEN'])) {
$token = $_SERVER['TERMINUS_MACHINE_TOKEN'];
}
$this->auth->logInViaMachineToken($token);
} elseif (isset($assoc_args['session'])) {
$this->auth->logInViaSessionToken($assoc_args['session']);
} else {
// Otherwise, do a normal email/password-based login.
if (empty($args)) {
if (isset($_SERVER['TERMINUS_USER'])) {
$email = $_SERVER['TERMINUS_USER'];
} else {
$email = Input::prompt(array('message' => 'Your email address?'));
}
} else {
$email = $args[0];
}
if (isset($assoc_args['password'])) {
$password = $assoc_args['password'];
} else {
$password = Input::promptSecret(array('message' => 'Your dashboard password (input will not be shown)'));
}
$this->auth->logInViaUsernameAndPassword($email, $password);
}
$this->log()->debug(get_defined_vars());
Terminus::launchSelf('art', array('fist'));
}
示例2: loadBackup
/**
* Loads a single backup
*
* @params array $assoc_args Parameters and flags from the command line
* @return bool Always true, else the function has thrown an exception
*/
private function loadBackup($assoc_args)
{
$assoc_args['to'] = '/tmp';
$assoc_args['element'] = 'database';
if (isset($assoc_args['database'])) {
$database = $assoc_args['database'];
} else {
$database = escapeshellarg(Input::prompt(array('message' => 'Name of database to import to')));
}
if (isset($assoc_args['username'])) {
$username = $assoc_args['username'];
} else {
$username = escapeshellarg(Input::prompt(array('message' => 'Username')));
}
if (isset($assoc_args['password'])) {
$password = $assoc_args['password'];
} else {
$password = Input::promptSecret(array('message' => 'Your MySQL password (input will not be shown)'));
}
exec('mysql --version', $stdout, $exit);
if ($exit != 0) {
$this->failure('MySQL does not appear to be installed on your server.');
}
$target = $this->getBackup($assoc_args);
$target = '/tmp/' . Utils\getFilenameFromUrl($target);
if (!file_exists($target)) {
$this->failure('Cannot read database file {target}', compact('target'));
}
$this->log()->info('Unziping database');
exec("gunzip {$target}", $stdout, $exit);
// trim the gz of the target
$target = Utils\sqlFromZip($target);
$target = escapeshellarg($target);
exec(sprintf('mysql %s -u %s -p"%s" < %s', $database, $username, $password, $target), $stdout, $exit);
if ($exit != 0) {
$this->failure('Could not import database');
}
$this->log()->info('{target} successfully imported to {db}', array('target' => $target, 'db' => $database));
return true;
}