PHPackages                             czproject/phpcli - 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. czproject/phpcli

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

czproject/phpcli
================

Helper class for PHP CLI apps.

v5.1.0(11mo ago)74.6k↓50%[1 issues](https://github.com/czproject/phpcli/issues)1BSD-3-ClausePHPPHP 8.0 - 8.4CI passing

Since Mar 9Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/czproject/phpcli)[ Packagist](https://packagist.org/packages/czproject/phpcli)[ Fund](https://www.janpecha.cz/donate/)[ RSS](/packages/czproject-phpcli/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (19)Used By (1)

PHP CLI Console
===============

[](#php-cli-console)

[![Build Status](https://github.com/czproject/phpcli/workflows/Build/badge.svg)](https://github.com/czproject/phpcli/actions)[![Downloads this Month](https://camo.githubusercontent.com/db367ed515adb9f3c037889cd1bf3cb4537abf504b53a94b080b32c79c30f9e3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f637a70726f6a6563742f706870636c692e737667)](https://packagist.org/packages/czproject/phpcli)[![Latest Stable Version](https://camo.githubusercontent.com/e0a3871d83b959f26ee96605d25f05e837860ef9f422272b0b636d97cf18edaa/68747470733a2f2f706f7365722e707567782e6f72672f637a70726f6a6563742f706870636c692f762f737461626c65)](https://github.com/czproject/phpcli/releases)[![License](https://camo.githubusercontent.com/fa7d5fcf2c84b580327af52da95dd751703af65f079dc3c5a0081beac0789718/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4e65772532304253442d626c75652e737667)](https://github.com/czproject/phpcli/blob/master/license.md)

[![Donate](https://camo.githubusercontent.com/101b981194f1dafbf9c42e19c3034fe2d724e75be972cef0f4477074997834db/68747470733a2f2f6275796d65636f666665652e696e746d2e6f72672f696d672f646f6e6174652d62616e6e65722e76312e737667)](https://www.janpecha.cz/donate/)

Installation
------------

[](#installation)

[Download a latest package](https://github.com/czproject/phpcli/releases) or use [Composer](http://getcomposer.org/):

```
composer require czproject/phpcli

```

PhpCli requires PHP 8.0 or later, optionaly [Readline extension](http://www.php.net/manual/en/book.readline.php).

Usage
-----

[](#usage)

```
use CzProject\PhpCli\ConsoleFactory;

require __DIR__ . '/vendor/autoload.php';

$console = ConsoleFactory::createConsole();

// output
$console->output('CzProject CLI Simple Console', 'green')
	->nl() // new line
	->output('Hey!', 'yellow')
	->nl()
	->output('Fred!', 'blue')
	->nl()
	->output('Fred is dead!', 'red')
	->nl()
	->output(['nooooooo...!', ' ', 'But, no problem!'], 'gray')
	->nl()
	->output('The end.')
	->nl();

// input
$username = $console->input('Enter your name');

$console->output('Hello! ', 'blue')
	->output($username, 'green')
	->output(' [user]', 'yellow')
	->nl() // print new line
	->output('Bye!', 'blue')
	->nl();

// input with default value
$username = $console->input('Enter your name', 'John');

// confirm
$agree = $console->confirm('Do you want to continue?');

// confirm with default value
$canQuit = $console->confirm('Really?', TRUE);

// select
$value = $console->select('Select color:', [
	'value' => 'label',
	'#ff0000' => 'Red',
	'#00ff00' => 'Green',
	'#0000ff' => 'Blue',
]);

// select with default value
$value = $console->select('Select color:', [
	'value' => 'label',
	'#ff0000' => 'Red',
	'#00ff00' => 'Green',
	'#0000ff' => 'Blue',
], '#ff0000');
```

Parameters
----------

[](#parameters)

**Arguments**

```
$name = $console->getArgument(0)->getValue(); // string|NULL

$size = $console->getArgument(1, 'int')
	->setRequired()
	->addRule(function ($value) {
		return $value > 0;
	})
	->getValue();

$price = $console->getArgument(2, 'float') // float
	->setDefaultValue(100.0)
	->getValue();
```

**Options**

```
$name = $console->getOption('name')->getValue(); // string|NULL

$size = $console->getOption('size', 'int')
	->setRequired()
	->addRule(function ($value) {
		return $value > 0;
	})
	->getValue();

$price = $console->getOption('price', 'float') // float
	->setDefaultValue(100.0)
	->getValue();

$words = $console->getOption('word')
	->setRepeatable()
	->getValue();
```

**Supported types**

- `string`
- `int` and `integer`
- `float`
- `bool` and `boolean`

---

License: [New BSD License](license.md)
Author: Jan Pecha,

###  Health Score

48

—

FairBetter than 95% of packages

Maintenance48

Moderate activity, may be stable

Popularity26

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity89

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 100% 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 ~279 days

Recently: every ~394 days

Total

17

Last Release

342d ago

Major Versions

v1.0.1 → v2.0.0-beta2013-09-01

v2.0.0 → v3.0.0-beta2017-12-11

v3.0.0 → v4.0.02021-02-14

v4.1.0 → v5.0.02023-04-06

PHP version history (2 changes)v4.0.0PHP &gt;=5.6.0

v5.1.0PHP 8.0 - 8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/5c980b1511b4a0350442dc23d89c99d4d9a2411b7e765d52c133ccacf616968b?d=identicon)[janpecha](/maintainers/janpecha)

---

Top Contributors

[![janpecha](https://avatars.githubusercontent.com/u/637719?v=4)](https://github.com/janpecha "janpecha (145 commits)")

---

Tags

phpphp-cli

### Embed Badge

![Health badge](/badges/czproject-phpcli/health.svg)

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

###  Alternatives

[wp-cli/wp-cli

WP-CLI framework

5.1k17.2M320](/packages/wp-cli-wp-cli)[consolidation/annotated-command

Initialize Symfony Console commands from annotated command class methods.

22569.8M19](/packages/consolidation-annotated-command)[seld/cli-prompt

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

24725.8M17](/packages/seld-cli-prompt)[illuminate/console

The Illuminate Console package.

12944.1M5.1k](/packages/illuminate-console)[php-tui/php-tui

Comprehensive TUI library heavily influenced by Ratatui

589747.0k6](/packages/php-tui-php-tui)[codedungeon/php-cli-colors

Liven up you PHP Console Apps with standard colors

10210.1M26](/packages/codedungeon-php-cli-colors)

PHPackages © 2026

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