seld/cli-prompt 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

seld/cli-prompt

最新稳定版本:1.0.4

Composer 安装命令:

composer require seld/cli-prompt

包简介

Allows you to prompt for user input on the command line, and optionally hide the characters they type

README 文档

README

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.

统计信息

  • 总下载量: 25.12M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 252
  • 点击次数: 1
  • 依赖项目数: 17
  • 推荐数: 0

GitHub 信息

  • Stars: 247
  • Watchers: 4
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04