seld/cli-prompt
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
$allowFallbackis set totruethe prompt will be done using the usualfgets()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.
seld/cli-prompt 适用场景与选型建议
seld/cli-prompt 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 26.6M 次下载、GitHub Stars 达 247, 最近一次更新时间为 2015 年 04 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「cli」 「console」 「input」 「prompt」 「hidden」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 seld/cli-prompt 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 seld/cli-prompt 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 seld/cli-prompt 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This class provides you with an easy-to-use interface to progress bars.
A Laravel package to retrieve data from Google Search Console
Yii2 map input widget. Allows you to select geographcal coordinates via a human-friendly inteface.
Widget to add a remaining character counter to text inputs and textareas
Additional artisan commands for Laravel
Native (browser) color input field for SilverStripe
统计信息
- 总下载量: 26.6M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 252
- 点击次数: 32
- 依赖项目数: 17
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-04-30