PHPackages                             iry/cli - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. iry/cli

ActiveLibrary[CLI &amp; Console](/categories/cli)

iry/cli
=======

PHP CLI Helper

v1.0.7(1y ago)21611[1 PRs](https://github.com/imroychen/php-cli/pulls)1MITPHPPHP &gt;=5.4

Since Jul 22Pushed 1y ago1 watchersCompare

[ Source](https://github.com/imroychen/php-cli)[ Packagist](https://packagist.org/packages/iry/cli)[ RSS](/packages/iry-cli/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (10)Used By (1)

\[中文\] / [English](./README-EN.md)\#简介

iry/Cli 可以简单实现 输出、输入、倒计时、绘制进度条、绘制表格、移动光标、清除屏幕、确认对话 等功能

可以轻松实现类似表单等输入功能：

如（input: *stdin*, 开关:*confirm*, select:select，radio:*select单选模式*, checkbox:*select多选模式*）

安装
==

[](#安装)

```
composer require iry/cli

```

使用方法
====

[](#使用方法)

环境控制 【可选】
=========

[](#环境控制-可选)

```
use ir\cli\Cli;
Cli::disableStyle(true|false)//是否禁用样式 默认false;
Cli::charset('gbk')//'utf-8', 'gbk', 'gb2312'//默认utf-8

```

示例
--

[](#示例)

标准输入
----

[](#标准输入)

stdin($msg,$validator,$processor);//等待并获取用户输入的数据

参数类型说明$msgstring消息：等待用户输入前，输一条提示消息消息$validatorfalse/callable验证器:用于验证用户输入的信息是否有效的方法$processorfalse/callable处理器:对用户输入的数据进行处理的方法```
use ir\cli\Cli;
$numeric = Cli::stdin('请输入');//等待并获取用户输入的数据
$numeric = Cli::stdin('请输入数字',function($v){return preg_match('/^[0-9]+$/',$v);},'trim');
$numeric = Cli::stdin('请输入数字',function($v){return preg_match('/^[0-9]+$/',$v);},'trim');
```

标准输出 output($msg,$styleType)
----------------------------

[](#标准输出-outputmsgstyletype)

打印到屏幕 支持彩色文字

参数说明$msgstring/array消息：等待用户输入前，输一条提示消息消息$styleTypestring/arrayerror,info,comment,question,highlight,warning,\[前景色,背景色\]$msg数组模式可以设置复杂的彩色文字如下示例### 示例

[](#示例-1)

```
Cli::output('这是一个测试','success')
Cli::output('这是一个测试','error')
Cli::output('这是一个测试',['purple','yellow'])
Cli::output([
    '这是',
    ['一个','error'],//使用error样式
    ['测试','yellow'],//使用info样式
    //string || ['$msg','$styleType']
]);
```

### 示例大致效果如下

[](#示例大致效果如下)

这是一个测试：
这是一个测试：
这是一个测试：
这是一个测试

### 确认对话

[](#确认对话)

confirm($msg,$validator,$processor);//Cli中 确认对话

参数说明$msgstring消息：等待用户输入前，输一条提示消息消息returnbooltrue/false$msg

```
use ir\cli\Cli;
$confirm = Cli::confirm('你确认要删除吗?');

//效果如下
//你确认要删除吗?[y/n] _
```

### 列表选择

[](#列表选择)

select($list,$colQty,$msg,$mul);

参数说明$listarray*必须*可选清单$colQtyint可选列数，展示可选清单时，展示几列。默认：1$msgstring可选默认：请输入$mulbool可选是否允许多选，默认：false### 移动光标

[](#移动光标)

cursorMove(方位,移动量) 方位：l:left r:right u:up, d:down

```
use ir\cli\Cli;
$confirm = Cli::cursorMove('u',3); //光标上移三行
$confirm = Cli::cursorMove('l',4); //光标左移4个字符
```

### 光标定位 *(移动光标到指定位置)*

[](#光标定位-移动光标到指定位置)

cursorPosition(x,y) y行x列

```
use ir\cli\Cli;
$confirm = Cli::cursorPosition(3,5);//光标定位到5行第三个字符后面
```

### clear

[](#clear)

clear();//清除屏幕

### wait (等待/倒计时/模拟loading 等场景)

[](#wait-等待倒计时模拟loading-等场景)

wait(int $s 秒,string $msg 消息);

### progressBar (进度条绘制)

[](#progressbar-进度条绘制)

progressBar(int $total 总量,int $current 当前量, string $msg 文本信息)

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~168 days

Total

8

Last Release

615d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/332367a6e49c4e91e2b816a39fdcecf212415f826cf0261981bc1db95075f6e2?d=identicon)[roychen](/maintainers/roychen)

---

Top Contributors

[![roy2chen](https://avatars.githubusercontent.com/u/4337618?v=4)](https://github.com/roy2chen "roy2chen (21 commits)")[![imroychen](https://avatars.githubusercontent.com/u/5027164?v=4)](https://github.com/imroychen "imroychen (2 commits)")

---

Tags

cliphp-clicliphp-cli

### Embed Badge

![Health badge](/badges/iry-cli/health.svg)

```
[![Health](https://phpackages.com/badges/iry-cli/health.svg)](https://phpackages.com/packages/iry-cli)
```

###  Alternatives

[symfony/console

Eases the creation of beautiful and testable command line interfaces

9.8k1.1B13.2k](/packages/symfony-console)[nunomaduro/collision

Cli error handling for console/command-line PHP applications.

4.6k348.7M10.4k](/packages/nunomaduro-collision)[nunomaduro/termwind

It's like Tailwind CSS, but for the console.

2.5k260.6M359](/packages/nunomaduro-termwind)[wp-cli/wp-cli

WP-CLI framework

5.1k18.5M386](/packages/wp-cli-wp-cli)[wp-cli/php-cli-tools

Console utilities for PHP

68327.0M372](/packages/wp-cli-php-cli-tools)[adhocore/cli

Command line interface library for PHP

3511.3M57](/packages/adhocore-cli)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
