PHPackages                             initphp/console - 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. initphp/console

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

initphp/console
===============

A simple helper library for writing console/CLI applications in PHP, including a styleable ANSI table renderer (formerly initphp/cli-table).

2.1.1(1mo ago)01091MITPHPPHP &gt;=7.2CI passing

Since Jul 6Pushed 3w ago1 watchersCompare

[ Source](https://github.com/InitPHP/Console)[ Packagist](https://packagist.org/packages/initphp/console)[ Docs](https://github.com/InitPHP/Console)[ RSS](/packages/initphp-console/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (4)Dependencies (3)Versions (8)Used By (1)

InitPHP Console
===============

[](#initphp-console)

A small, dependency-free helper library for writing console / CLI applications in PHP — command routing, typed arguments, coloured output, interactive questions and a styleable ANSI table renderer.

[![CI](https://github.com/InitPHP/Console/actions/workflows/ci.yml/badge.svg)](https://github.com/InitPHP/Console/actions/workflows/ci.yml)[![Latest Stable Version](https://camo.githubusercontent.com/d8c8e4ba0a9e5abf34178baf154e96f27e9a1d8ff637f277aa1280c06af87f8f/68747470733a2f2f706f7365722e707567782e6f72672f696e69747068702f636f6e736f6c652f762f737461626c65)](https://packagist.org/packages/initphp/console)[![Total Downloads](https://camo.githubusercontent.com/c516947cd0344cb15323f69b370f5e315c547aac6f46424a4f83c16e6360f93c/68747470733a2f2f706f7365722e707567782e6f72672f696e69747068702f636f6e736f6c652f646f776e6c6f616473)](https://packagist.org/packages/initphp/console)[![License](https://camo.githubusercontent.com/83a027c296f8cfba41727edfdb69610c4d4495c1ee81563dacd8d66deefd657e/68747470733a2f2f706f7365722e707567782e6f72672f696e69747068702f636f6e736f6c652f6c6963656e7365)](./LICENSE)[![PHP Version Require](https://camo.githubusercontent.com/5ef6b4b1f4d4c5cccbdd36f49917366180138832c0b551d33018198b23f63c5c/68747470733a2f2f706f7365722e707567782e6f72672f696e69747068702f636f6e736f6c652f726571756972652f706870)](https://packagist.org/packages/initphp/console)

> Starting with **2.1** this package also ships the ANSI table renderer that used to be distributed as the separate [`initphp/cli-table`](https://github.com/InitPHP/CLITable) package (now deprecated). See [Migrating from `initphp/cli-table`](#migrating-from-initphpcli-table).

Features
--------

[](#features)

- **Command routing** — register commands as closures or as classes extending `Command`.
- **Grouped help** — automatic `help` / `list` overview and per-command `--help` usage.
- **Typed arguments** — declare `--name` arguments with a type (`INT`, `FLOAT`, `BOOL`, …), a default and an optional/required flag; values are validated automatically.
- **Input parsing** — long arguments (`--name=value`), short options (`-v`, `-abc`, `-k=value`) and bare positional segments, with automatic scalar type casting.
- **Coloured output** — 16/256-colour SGR helpers, message styles (`error`, `success`, `warning`, `info`), key/value lists and a progress bar.
- **Interactive prompts** — free-form `ask()` and option-constrained `question()`.
- **Table rendering** — a styleable, multibyte-aware ASCII/ANSI table.
- **Testable I/O** — output and input streams are injectable, so commands can be unit tested without touching `STDOUT`/`STDIN`.

Requirements
------------

[](#requirements)

- PHP **7.2** or higher
- `ext-mbstring` *(optional)* — improves table alignment for multibyte (UTF-8) values

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

[](#installation)

```
composer require initphp/console
```

Quick start
-----------

[](#quick-start)

Create an entry script (e.g. `console.php`):

```
#!/usr/bin/env php
